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

Discussion in 'Perl Misc' started by amirkargerweb@yahoo.com, Jan 12, 2005.

  1. Guest

    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
     
    , Jan 12, 2005
    #1
    1. Advertising

  2. Guest

    wrote:
    > 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?


    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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Jan 12, 2005
    #2
    1. Advertising

  3. writes:
    >
    > 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.


    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.
     
    Arndt Jonasson, Jan 13, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. U. George
    Replies:
    4
    Views:
    844
    U. George
    Aug 11, 2005
  2. Laszlo Nagy
    Replies:
    0
    Views:
    741
    Laszlo Nagy
    May 31, 2007
  3. Une Bévue
    Replies:
    0
    Views:
    524
    Une Bévue
    Sep 7, 2008
  4. Replies:
    5
    Views:
    452
    Gunnar Hjalmarsson
    Jul 2, 2006
  5. Krishna Chaitanya
    Replies:
    1
    Views:
    144
    Krishna Chaitanya
    Feb 27, 2009
Loading...

Share This Page