#include <stropts.h>
int isastream (int fildes);
#include <stdio.h>
#include <stropts.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
int fd;
int i;
if (argc < 2) {
printf ("Usages: isastreamm file ...");
exit (EXIT_FAILURE);
}
for (i = 0; i < argc; i++) {
if ((fd = open (argv [i], O_RDONLY)) == -1) {
printf ("Can't open %s", argv [i]);
continue;
}
printf ("%s %s a STREAMS device\n", argv [i], (isastream (fd)) ? "is" : "is not");
}
return (0);
}
[beyes@localhost STREAMS]$ ./isastream.exe /dev/tty /dev/null
./isastream.exe is not a STREAMS device
/dev/tty is not a STREAMS device
/dev/null is not a STREAMS device
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |