delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/03/08/04:42:53

Date: Sat, 08 Mar 2003 11:32:44 +0200
From: "Eli Zaretskii" <eliz AT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: rich AT phekda DOT freeserve DOT co DOT uk
Message-Id: <3028-Sat08Mar2003113243+0200-eliz@elta.co.il>
X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9
CC: djgpp-workers AT delorie DOT com
In-reply-to: <3E6938EC.D9BFE2E4@phekda.freeserve.co.uk> (message from Richard
Dawe on Sat, 08 Mar 2003 00:27:24 +0000)
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> <3E6938EC DOT D9BFE2E4 AT phekda DOT freeserve DOT co DOT uk>
Reply-To: Eli Zaretskii <eliz AT elta DOT co DOT il>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Sat, 08 Mar 2003 00:27:24 +0000
> From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
> 
> 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)?

Wait a minute, there's something I missed when I looked at that code:
why do we need to disallow pwrite on redirected standard handles?
Redirected standard handles are just normal files on DOS/Windows, so
why should pwrite fail on them?

> With stdin, stdout, stderr we can assume they are pipes

You can't, really.  A redirected standard output could be a disk file,
as in "foo > bar".  What you are thinking about is "foo | bar", but
that doesn't have to be so, and we have no way of distinguishing
between these two possible uses of redirection.

> BTW stdaux and stdprn are not TTYs according to isatty(). Is this a bug?

No, I don't think so.  See my other mail in this thread.

- Raw text -


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