From mboxrd@z Thu Jan 1 00:00:00 1970 From: dave@horsfall.org (Dave Horsfall) Date: Mon, 15 Aug 2016 10:41:02 +1000 (EST) Subject: [TUHS] fstat(2) on pipes? In-Reply-To: <20160815001140.GA16138@minnie.tuhs.org> References: <20160815001140.GA16138@minnie.tuhs.org> Message-ID: On Mon, 15 Aug 2016, Warren Toomey wrote: > All, sorry this is slightly off-topic. I'm trying to find out what > fstat(2) returns when the file descriptor is a pipe. The POSIX/Open > Group documentation doesn't really specify what should be returned. Does > anybody have any pointers? I always thought it was undefined, but my Mac says: BUGS Applying fstat to a socket (and thus to a pipe) returns a zero'd buffer, except for the blocksize field, and a unique device and inode number. And my FreeBSD box is the same; I haven't checked my Penguins. > P.S. Why? xv6 has fstat() but returns an error if the file descriptor > isn't associated with an i-node. I'm trying to work out if/how to fix > it. Probably not much use to you, but back in Ed6 I did modify it to return the amount of data in the pipe. -- Dave Horsfall DTM (VK2KFU) "Those who don't understand security will suffer."