[TUHS] fstat(2) on pipes?
michael at kjorling.se
Tue Aug 16 02:56:45 AEST 2016
On 15 Aug 2016 11:14 -0400, from random832 at fastmail.com (Random832):
> On Mon, Aug 15, 2016, at 10:04, Noel Chiappa wrote:
>> But back to the original topic, it sounds like there's a huge amount
>> of variance in the semantics of doing fstat() on a pipe. V6 doesn't
>> special-case it in any way, but it sounds as if other systems do.
> I expect that the single important thing, the only thing that most
> applications will rely on, is it returning successfully and indicating
> that the file type is fifo.
On Linux/glibc, based on the fstat(2) man page, it looks like the size
field is undefined for a FIFO:
> The st_size field gives the size of the file (if it is a regular
> file or a symbolic link) in bytes. The size of a symbolic link is
> the length of the pathname it contains, without a terminating null
The mode field is used to hold the type of file:
> The following POSIX macros are defined to check the file type using
> the st_mode field:
> S_ISFIFO(m) FIFO (named pipe)?
> The following flags are defined for the st_mode field:
> S_IFIFO 0010000 FIFO
The above from Debian Wheezy.
Michael Kjörling • https://michael.kjorling.se • michael at kjorling.se
“People who think they know everything really annoy
those of us who know we don’t.” (Bjarne Stroustrup)
More information about the TUHS