perl – inappropriate ioctl for device

perl – inappropriate ioctl for device

Most likely it means that the open didnt fail.

When Perl opens a file, it checks whether or not the file is a TTY (so that it can answer the -T $fh filetest operator) by issuing the TCGETS ioctl against it. If the file is a regular file and not a tty, the ioctl fails and sets errno to ENOTTY (string value: Inappropriate ioctl for device). As ysth says, the most common reason for seeing an unexpected value in $! is checking it when its not valid — that is, anywhere other than immediately after a syscall failed, so testing the result codes of your operations is critically important.

If open actually did return false for you, and you found ENOTTY in $! then I would consider this a small bug (giving a useless value of $!) but I would also be very curious as to how it happened. Code and/or truss output would be nifty.

Odd errors like inappropriate ioctl for device are usually a result of checking $! at some point other than just after a system call failed. If youd show your code, I bet someone would rapidly point out your error.

perl – inappropriate ioctl for device

inappropriate ioctl for device is the error string for the ENOTTY error. It used to be triggerred primarily by attempts to configure terminal properties (e.g. echo mode) on a file descriptor that was no terminal (but, say, a regular file), hence ENOTTY. More generally, it is triggered when doing an ioctl on a device that does not support that ioctl, hence the error string.

To find out what ioctl is being made that fails, and on what file descriptor, run the script under strace/truss. Youll recognize ENOTTY, followed by the actual printing of the error message. Then find out what file number was used, and what open() call returned that file number.

Leave a Reply

Your email address will not be published. Required fields are marked *