Named pipes on the UNIX PC, is there a problem with ls(1)?
Lenny Tropiano
lenny at icus.islp.ny.us
Mon Sep 26 11:46:24 AEST 1988
The "mknod(1M)" command can be used to create character and block
devices, as well as, FIFO's or named pipes. mknod(1M) needs to
be run as the super-user if you are creating anything but fifo's.
Usage: mknod name c|b maj min
-or- mknod name p
Normally when you create a named pipe, the ls(1) command signifies this
the same as it does with directories (d), character devices (c), and
block devices (b) with "p". For some reason this doesn't work. For
example the file /usr/spool/lp/FIFO is a named pipe, but the directory
doesn't tell us.
$ ls -l /usr/spool/lp/FIFO
-rw------- 1 lp other 0 Sep 25 19:42 /usr/spool/lp/FIFO
^
Here should be a "p".
Here's a short program to test for FIFO status:
/* isfifo.c */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
main(argc,argv)
int argc;
char *argv[];
{
struct stat statbuf;
if (argc < 2) {
printf("usage: %s file\n", argv[0]);
exit(1);
}
if (stat(argv[1],&statbuf) < 0) {
perror("stat()");
exit(1);
}
printf("%s", argv[1]);
if (statbuf.st_mode & S_IFIFO)
printf(" is ");
else
printf(" isn't ");
printf("a fifo\n");
}
$ isfifo isfifo.c
isfifo.c isn't a fifo
$ isfifo /usr/spool/lp/FIFO
/usr/spool/lp/FIFO is a fifo
Why can't ls(1) do this too? I've seen it work elsewhere.
-Lenny
---
Lenny Tropiano ICUS Software Systems w: +1 (516) 582-5525
lenny at icus.islp.ny.us Telex: 154232428 ICUS h: +1 (516) 968-8576
{talcott,boulder,hombre,pacbell,sbcs}!icus!lenny attmail!icus!lenny
ICUS Software Systems -- PO Box 1; Islip Terrace, NY 11752
More information about the Comp.sys.att
mailing list