http://qs321.pair.com?node_id=11120510


in reply to Re^2: Should I worry about "Inappropriate ioctl for device"? (updated)
in thread Should I worry about "Inappropriate ioctl for device"?

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

Replies are listed 'Best First'.
Re^4: Should I worry about "Inappropriate ioctl for device"? (updated)
by jcb (Parson) on Aug 09, 2020 at 02:29 UTC

    Most likely, errno (the system C variable behind the $! magic) was used uninitialized in both cases. The C runtime library never clears errno and only sets errno to report an error. If no such error has occurred since the program started, the value of errno is undefined, which (in C) means unspecified — it is still an integer, as there is no undef value in C. (NULL pointers are a related but slightly different concept — if you could dereference a NULL pointer, you would logically get undef. In reality, you get SIGSEGV if you dereference a NULL pointer and your program crashes.)

      More likely still, some part of the C library is doing a terminal-related ioctl() system call on one of the standard filehandles like STDIN, finding that its not in fact a terminal (e.g. because STDIN hs been redirected) and safely ignoring the harmless error. I.e. the C library logic is along the lines of "if this file handle is a terminal do some extra initialisation, otherwise don't worry about it".

      I used to see this on Solaris all the time when doing a truss(1); I don't see it on linux though.

      Dave.

        Updating myself: I can see it on linux too: an ioctl(fh, TCGETS) system call is being done on each file handle that gets opened.

        Dave.

Re^4: Should I worry about "Inappropriate ioctl for device"? (updated)
by AnomalousMonk (Archbishop) on Aug 09, 2020 at 08:29 UTC
    ... [why would I] get a message about inappropriate use of ioctl in one script but not another.

    Perhaps because $! is being used inappropriately in one script and not in the other. Beyond that, I must confess that I'm confused about the current state of your code and can say no more.


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

      Everyone is confused by my code in general. I'm used to it,

      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

        Now you mention it, been there, done that too. :)


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