$! is set to "Inappropriate ioctl..." on Linux

A

amirkargerweb

Hi.

Running perl5.8.* on Linux (more details later), I get:

==============
echo 'hi' > zzz
echo 'bye' >> zzz
perl -we 'print ".$\!.\n";open FOO, "<zzz" or die "foo\n";print
".$\!.\n"; print <FOO>'
...
..Inappropriate ioctl for device.
hi
bye
==============

- Why is $! getting set if the open was successful?
- My open command seems pretty darn simple. Am I doing something wrong?
- Is this a known issue?

More details:
This problem happened on a variety of 2.4 RedHat Linux kernels (Intel
and AMD), plus Mandrake 2.6. It did NOT happen on OS X 10.3, Solaris 9
on SPARC, or Digital Unix.
Any thoughts?

Thanks,

-Amir Karger
(e-mail address removed)
 
X

xhoster

Hi.

Running perl5.8.* on Linux (more details later), I get:

==============
".$\!.\n"; print <FOO>'
..
.Inappropriate ioctl for device.
hi
bye
==============

- Why is $! getting set if the open was successful?

Take a look at the friendly docs.

$! If used numerically, yields the current value of the C
"errno" variable, or in other words, if a system or library
call fails, it sets this variable. This means that the
value of $! is meaningful only immediately after a failure:

You aren't immediately after a failure. The value of $! is meaningless.

Xho
 
A

Arndt Jonasson

Running perl5.8.* on Linux (more details later), I get:

==============
".$\!.\n"; print <FOO>'
..
.Inappropriate ioctl for device.

This is the classical Unix "Not a typewriter" error that appears
if you check 'errno' after doing some I/O although nothing went wrong.
The reason is usually that the standard I/O routines check whether
stdout is a terminal or not and sets buffering accordingly. This check
results in an error from a system call in case stdout is not a
"typewriter", i.e., "tty", i.e., terminal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top