delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/03/07/19:27:37

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 <rich AT phekda DOT freeserve DOT co DOT uk>
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 <djgpp-workers AT delorie DOT com>
Subject: Re: New POSIX: pwrite [PATCH]
References: <E18rMih-00011k-00 AT phekda DOT freeserve DOT co DOT uk> <200303071845 DOT h27Ij5d18334 AT envy DOT delorie DOT com>
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/ ]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019