“设备的不适当的ioctl" [英] "inappropriate ioctl for device"
问题描述
我在AIX框中运行一个Perl脚本.
I have a Perl script running in an AIX box.
该脚本尝试从某个目录打开文件,但由于文件没有读取权限,因此无法读取该文件,但是出现了另一个错误,提示inappropriate ioctl for device
.
The script tries to open a file from a certain directory and it fails to read the file because file has no read permission, but I get a different error saying inappropriate ioctl for device
.
它不是应该说类似no read permissions for file
之类的话吗?
Shouldn't it say something like no read permissions for file
or something similar?
此inappropriate ioctl for device
消息是什么意思?
我该如何解决?
这是我做strace
时发现的.
open("/local/logs/xxx/xxxxServer.log", O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE,
0666) = 4 _llseek(4, 0, [77146], SEEK_END) = 0
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbffc14f8) = -1 ENOTTY
(Inappropriate ioctl for device)
推荐答案
最有可能意味着打开的不会失败.
Most likely it means that the open didn't fail.
当Perl打开文件时,它将通过向文件发出TCGETS
ioctl来检查该文件是否为TTY(以便它可以回答-T $fh
filetest运算符).如果文件是常规文件而不是tty,则ioctl失败并将errno设置为ENOTTY
(字符串值:设备的不适当的ioctl").如ysth所说,在$!
中看到意外值的最常见原因是在无效时进行检查-即在 other 以外的地方,而不是在系统调用失败后立即进行检查,因此测试结果代码您的运营至关重要.
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 it's not valid -- that is, anywhere other than immediately after a syscall failed, so testing the result codes of your operations is critically important.
如果open
实际上确实为您返回了false,并且您在$!
中找到了ENOTTY
,那么我会认为这是一个小错误(给出了$!
的无用值),但我也很好奇怎么发生的.代码和/或桁架输出会很漂亮.
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.
这篇关于“设备的不适当的ioctl"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!