Mail Archives: djgpp-workers/2003/03/08/04:42:53
> 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 -