ls & file pipes (FIFO), curses...

Art Neilson art at pilikia.pegasus.com
Thu Feb 21 05:49:48 AEST 1991


In article <avalon.666979740 at coombs> avalon at coombs.anu.edu.au (avalon) writes:
>G'day, can anyone tell me how 'ls' knows whether a
>file is a regular file or a pipe ?
>
>When i do a stat(2) call on the file, it is returned
>as a regular file.  What tricks does ls perform ?

Here's an example of testing if a file is a pipe or not:

	if (stat(pathname, &st) == -1) {
		perror("stat");
		exit(1);
	}

	if ((st.st_mode & S_IFMT) == S_IFIFO)
		printf("%s is a fifo\n", pathname);

-- 
Arthur W. Neilson III		| INET: art at pilikia.pegasus.com
Bank of Hawaii Tech Support	| UUCP: uunet!ucsd!nosc!pegasus!pilikia!art



More information about the Comp.unix.internals mailing list