+ -
当前位置:首页 → 问答吧 → perl读写文件Inappropriate ioctl for device算是perl的一个bug??

perl读写文件Inappropriate ioctl for device算是perl的一个bug??

时间:2010-10-27

来源:互联网

Code:

           use FileHandle;

           $fh = new FileHandle;
           if ($fh->open("< file")) {
               print <$fh>;
               $fh->close;
           }

在终端环境下:


When Perl opens a file, it checks whether or not the terminal 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.

作者: 027xiatian   发布时间: 2010-10-27

"< file"
这个不就是个文件名吗?
不懂

作者: nuclearxin   发布时间: 2010-10-28