Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3E6938EC.D9BFE2E4@phekda.freeserve.co.uk> Date: Sat, 08 Mar 2003 00:27:24 +0000 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: DJGPP workers Subject: Re: New POSIX: pwrite [PATCH] References: <200303071845 DOT h27Ij5d18334 AT envy DOT delorie DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Hello. DJ Delorie wrote: [snip] > > + /* Is this a redirected standard handle: stdout, stderr? > > + * I.e.: are the standard handles pipes? Disallow on pipes. */ > > + switch(fd) { > > + case STDOUT_FILENO: > > + case STDERR_FILENO: > > + if (isatty(fd) == 0) { > > Why not just call isatty() for all fds? stderr/stdout aren't the only > fds that can be redirected. Consider that at least stdaux and stdprn > are also ttys. [snip] But is there any easy way we can distinguish between pipes and (regular files, character devices)? With stdin, stdout, stderr we can assume they are pipes, if they are not TTYs. But we can't assume that for other file descriptors - we can use fd_props, if available, to find out. Hence the code only checks stdout & stderr using isatty(). BTW stdaux and stdprn are not TTYs according to isatty(). Is this a bug? Bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]