Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Should I worry about "Inappropriate ioctl for device"?

by Lady_Aleena (Curate)
on Aug 07, 2020 at 12:29 UTC ( #11120464=perlquestion: print w/replies, xml ) Need Help??

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

I just saw that one of my dies returned "Inappropriate ioctl for device" at the end of the string I wanted to be returned. Is it something I need to worry about, or can I safely ignore it? I've tried to figure out what it means, and what I did wrong from various Google searches and reading here and elsewhere about it. I just do not understand it. So, other than knowing that "ioctl" stands for "input/output control" and I did something inappropriate with it, I am a bit lost.

So, do I dive in and drive myself a little crazy trying to figure it out? Can I safely ignore it, not letting it worry me? Could it bite me later?

Here is the code where I got the message.

die "$_ isn't using strict, $!" if ($loop == 1 && $line !~ /use st +rict/ && $_ !~ /index/); die "$_ isn't using strict, $!" if ($loop == 2 && $line !~ /use st +rict/ && $_ =~ /index/); die "$_ isn't using warnings, $!" if ($loop == 2 && $line !~ /use wa +rnings/ && $_ !~ /index/); die "$_ isn't using warnings, $!" if ($loop == 3 && $line !~ /use wa +rnings/ && $_ =~ /index/);

My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re: Should I worry about "Inappropriate ioctl for device"?
by choroba (Archbishop) on Aug 07, 2020 at 13:03 UTC
    Inspecting $! only makes sense when you know it was set, e.g. in open ... or die $!;. If you didn't run any function that sets $!, or you ran it but it didn't fail, the contents of $! could be anything.

    Somehow mentioned in $!.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      I was just wondering if this was something I should go through all my work and fix now, or can it wait until later? Is it a critical flaw in my writing? Could an inappropriate use of $! bite me sooner rather than later?

      I have been tacking $! onto the end of every string I use in die and warn since I was told to use it there. I had not looked into what it was doing or how it worked. I have been using it because I was told to use it on one occasion, probably when I first used die with an open.

      Please forgive me for not knowing my use of $! was not appropriate in the case in my OP. Should this be urgent, I will go through my work and make the needed changes.

      My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
        If you use it just in the messages coming from die or warn, it's confusing, but not critical. Basing the program flow on the value would be a critical problem, though:
        ... die $! if $!; # Can stop your program for no real reason.
        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        Lady_Aleena:

        If you didn't run any function that sets $!, or you ran it but it didn't fail, the contents of $! could be anything.
        E.g.:
        c:\@Work\Perl\monks>perl -wMstrict -le "print 0+$!, qq{ == '$!'}; " 9 == 'Bad file descriptor'


        Give a man a fish:  <%-{-{-{-<

Re: Should I worry about "Inappropriate ioctl for device"?
by hippo (Chancellor) on Aug 07, 2020 at 12:37 UTC

    That's merely the contents of $! at the time your die is called. You need to find out what it is prior to this which is setting $! to that string then you'll be in a position to fix it.

    You are using warnings, I presume?


    🦛

      Yes I am using warnings, and they are FATAL for this script.

      My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
Re: Should I worry about "Inappropriate ioctl for device"?
by Lady_Aleena (Curate) on Aug 09, 2020 at 00:33 UTC

    Now I am confused a bit. The $! in the following, when it died, did not tell me that I was using ioctl inappropriately. The reason I am confused is that the lines of code in my OP were inside-out conditionals (don't remember where I got that term), but the code below is just a conditional too.

    My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena

      Nothing in the code you show does anything that would give $! a meaningful value. The value $! actually has at the moment the code shown is executed was either set in some previous operation that gave $! a meaningful value (update: see this), or else it's the value $! happened to have at program startup (update: see this), i.e., random. Either way, its value is meaningless.

      Update: Consider this code:

      c:\@Work\Perl\monks>perl -wMstrict -le "my $year = 987; $! = 0; if ($year !~ /\d{4}/) { die qq{Idiot!, use 4 digit year. Stopped '$!' +} } " Idiot!, use 4 digit year. Stopped '' at -e line 1.
      Now try assigning different values (1, 2, 3, ...) to $! and see what messages you get. The messages you're seeing in your posted code are just cruft.


      Give a man a fish:  <%-{-{-{-<

        I forgot to mention, I already took $! out of that code. I am still a little confused by why I would get a message about inappropriate use of ioctl in one script but not another.

        Also, I just checked the rest of my code and removed all the other inappropriate uses of ioctl that I could find. All those that are left are with opens.

        My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

        No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
        Lady Aleena
      ... inside-out conditionals ...

      NB: I'm guessing this refers to a statement modifier, but "inside-out conditional" is a good description too!


      Give a man a fish:  <%-{-{-{-<

        Found it! Perl Optimization Tidbits by Daina Petit at 27:03 mark. The link is to that spot in the video.

        My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

        No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
        Lady Aleena

        I've been trying to remember where I got that term, and I think I got it from a talk by Daina Petit on YouTube where he used it to refer to an inside-out for.

        My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

        No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
        Lady Aleena

      You may read this by brian_d_foy. $ERRNO is not what you want.

      One option might be to rewrite you code like this:

      sub four_digit_year { my $year = shift; if ( $year !~ /\d{4}/ ) { return; # undef } return $year; }

      Then check if the result of your sub call is defined and die with some custom error message if not.

      And probably you may find a more robust recipe on PM how to test if some date is valid.

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re: Should I worry about "Inappropriate ioctl for device"?
by Anonymous Monk on Aug 08, 2020 at 02:55 UTC
    No, don't ignore this. You have a bug. Better now than later.
      lol. what would you know about it? lol

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-09-27 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I don’t succeed, I …










    Results (142 votes). Check out past polls.

    Notices?