Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Inappropriate ioctl for device

by adisi (Initiate)
on Jul 21, 2008 at 12:59 UTC ( [id://699034]=perlquestion: print w/replies, xml ) Need Help??

adisi has asked for the wisdom of the Perl Monks concerning the following question:

Hi, The following code:

#!/usr/bin/perl open (FH,"test.txt"); close(FH);
straced, gives:
open("test.txt", O_RDONLY|O_LARGEFILE) = 3 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe83bf8) = -1 ENOTTY (Inapp +ropriate ioctl for device)

I'm using Perl version 5.8.8 on a CentOS release 5.2 (2.6.18-92.1.1.el5), but this behaviour occures
also on Red Hat Enterprise Linux AS release 4 (2.6.9-55.ELsmp) with perl 5.8.5 on it.

At first I suspected that it has something to do with the O_LARGEFILE flag, but I compiled perl again without
largefile support, and the same error appears.

The script itself isn't affected by this error (at least so it seems), the file is being opened and everything seems well.

My question is, should I be concerned about this error? I saw a lot of these cases over the internet but not one solution.
I'd be happy for an advice on how to get rid of this error.

Thanks,

Adi.

Replies are listed 'Best First'.
Re: Inappropriate ioctl for device
by almut (Canon) on Jul 21, 2008 at 13:36 UTC
    should I be concerned about this error?

    No. Not every failing system call is indicative of a problem. In fact, it's pretty normal to see many system calls return with an error code.  In many cases it's faster/easier/the-only-way to just make the call and react appropriately, rather than trying to determine beforehand whether the call would fail... (it's kinda like simply asking the question, instead of "May I ask a question?", followed by the question if you get "Yes" :)

      Additionally, if you ask if you can ask a question and then ask, there is a race condition where the ability to ask the question may change, so you have to check the response code anyway.

      --MidLifeXis

      ... for a simple example of this (an abundance of not entirely unexpected errors), you only have to trace a perl script that 'use'es a module from a non-standard location - you'll see any amount of ENOEXIST errors before perl manages to locate and open the 'use'd module.

      At last, a user level that overstates my experience :-))
Re: Inappropriate ioctl for device
by moritz (Cardinal) on Jul 21, 2008 at 13:27 UTC
    The script itself isn't affected by this error (at least so it seems), the file is being opened and everything seems well.

    Before making such statements, check for the return value of open and close first:

    open FH, "test.txt" or die "Can't open file: $!"; close FH or die "Can't close file: $!";

    or even use Fatal qw(open close);

    I can't answer your question though.

Re: Inappropriate ioctl for device
by pc88mxer (Vicar) on Jul 21, 2008 at 15:42 UTC
    As almut says, this is nothing to worry about. If you carefully look at your strace output, you'll see that perl even performs a TCGETS ioctl on the your script file!

    Perl makes other information gathering calls when it opens a file such as calling _llseek with whence set to SEEK_CUR. You might wonder why perl has to ask what the file position is if it just opened a file. It turns out that it's logically cleaner to always ask rather than assume.

      # Grab the first word... if ( $! =~ /Inappropriate/i ) { # Bug in perl 5.8.6... we're ignoring this message... (I +nappropriate ioctl for device) Warning... } else { print "System Message on Open --> $! \n" ; print "Not fatal if the file doesn't exist, because the open +will create the file...\n"; print "Continuing... \n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://699034]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-25 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found