LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 743|回复: 0

isastream出问题?

[复制链接]
发表于 2006-3-3 09:07:36 | 显示全部楼层 |阅读模式
#include <stropts.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <stdio.h>

int isastream (int fd)
{
        return ( ioctl(fd, I_CANPUT,0) !=-1) ;

}


int main(int argc, char *argv[])
{
        int i,fd;
        if (argc <=1 )  
                {
                        perror ("argc too few");
                        exit (1);
                }
        for (i=1; i<argc; i++)
        {
                printf("%s:\t", argv);
                if (  (fd =open(argv,O_RDONLY))<0 )
                {
                        printf("%s:can't open\n", argv);
                        continue;
               
                }
               
                if ( isastream(fd) ==0 )
                         printf("%s:not a stream\n", argv);
                          
                         
                else
                         printf("%s: is a stream\n", argv);
       
        }
        exit (0);


}
    运行后  ./isastream /dev/null /dev/tty
结果却都是/dev/tty:       /dev/tty:not a stream
          /dev/null:      /dev/null:not a stream
这时怎么回事?
    按AUPE  book上写的, 请问结果跟系统有关系吗?我的是FC2
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表