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

uunet!bria!mike uunet!bria!mike
Thu Feb 21 03:29:53 AEST 1991


In an article, coombs.anu.edu.au!avalon (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 ?

A file that is a named pipe shoould have S_IFIFO set in st_mode;
such as:

	if ( stat(file,&buf) != -1 && buf.st_mode & S_IFIFO )
		printf("%s is a pipe\n",file);

Cheers,
-- 
Michael Stefanik, MGI Inc., Los Angeles| Opinions stated are not even my own.
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
Remember folks: If you can't flame MS-DOS, then what _can_ you flame?



More information about the Comp.unix.programmer mailing list