This is the mail archive of the
mailing list for the Cygwin project.
Re: Problem redirecting stderr to pipe in subprocess
On Oct 10 18:06, Christopher Faylor wrote:
> On Sun, Oct 09, 2011 at 07:58:15PM -0400, Christopher Faylor wrote:
> >On Sat, Oct 08, 2011 at 05:39:20PM -0400, Ken Brown wrote:
> >>Attached is a slight modification of the STC, in which I set stdin for
> >>the bash subprocess to /dev/null. With this modification, the program
> >>works as expected (and as on Linux) with cygwin-1.7.9, but the same
> >>problem as before occurs with the latest snapshot.
> >I can duplicate this problem. I'll take a look.
> >Thanks for the STC.
> As far as I can tell, this is arguably a bug in bash. It's also an
> annoying compatibility problem between Linux and Cygwin.
> When the tty layer in Cygwin was first developed, the model (either in
> my head or in reality) was "If you don't have a tty and open a tty, that
> becomes your controlling tty". But, apparently that model changed over
> time to something more sensical where you have to explicitly use
> ioctl(TIOCSCTTY) to set up a controlling terminal.
I don't quite understand this. The "If you don't have a tty and open a tty,
that becomes your controlling tty" is standard POSIX behaviour, isn't it?
SUSv4 open writes:
If set and path identifies a terminal device, open() shall not
cause the terminal device to become the controlling terminal for
the process. If path does not identify a terminal device,
O_NOCTTY shall be ignored.
The Linux man page contains basically the same.
> On Linux systems
> that would presumably be done via login(1). We don't normally run login
> on Cygwin, though.
> The problem is that when there is no controlling tty, bash uses a
> fallback mechanism to find the name of the tty by opening the tty
> associated with fd 0. It does this without setting the O_NOCTTY
> flag and, so, the act of opening the fd assigns a controlling
That sounds correct to me.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple