This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: Getting the terminal while in the background.
- From: "Pierre A. Humblet" <pierre dot humblet at ieee dot org>
- To: chet at po dot cwru dot edu
- Cc: cygwin-developers at cygwin dot com, ronald at landheer dot com
- Date: Mon, 04 Oct 2004 15:10:55 -0400
- Subject: Re: Getting the terminal while in the background.
- References: <3.0.5.32.20040928232925.0082e850@verizon.net> <041004183640.AA18441.SM@caleb.ins.cwru.edu>
- Reply-to: pierre dot humblet at ieee dot org
Chet Ramey wrote:
>
> > Under Cygwin, the command below gives rise to a warning:
> >
> > ~: true | `echo true` &
> > [1] 380723
> > ~: Use "logout" to leave the shell.
> > [1]+ Done true | `echo true`
> >
> > I found the explanation, please bear with me.
>
> Thanks for the detailed explanation.
>
> > There are 4 processe involved:
> > the main interactive pid M
> > a subprocess A evaluating the first true,
> > a subprocess B evaluating `echo true',
> > which still has "interactive" = 1,
> > and forking a subprocess C that evaluates the second true.
> >
> > What's happening is that process B has
> > subshell_environment 0x18 = SUBSHELL_PIPE | SUBSHELL_FORK
> > Accordingly in command_substitute() it sees
> > if ((subshell_environment & SUBSHELL_PIPE) == 0)
> > pipeline_pgrp = shell_pgrp;
> > and it does NOT set pipeline_pgrp to shell_pgrp.
> > It then calls make_child() with async_p = 0.
>
> This is the problem. The code as written makes SUBSHELL_ASYNC and
> SUBSHELL_PIPE mutually exclusive; they are not.
>
> Correcting this fixes the problem.
Thanks Chet.
You mean something like the following, or is there more to it?
@@ -2518,9 +2518,11 @@ execute_simple_command (simple_command,
already_forked = 1;
simple_command->flags |= CMD_NO_FORK;
- subshell_environment = (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
- ? (SUBSHELL_PIPE|SUBSHELL_FORK)
- : (SUBSHELL_ASYNC|SUBSHELL_FORK);
+ subshell_environment = SUBSHELL_FORK;
+ if (async)
+ subshell_environment |= SUBSHELL_ASYNC;
+ if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
+ subshell_environment |= SUBSHELL_PIPE;
/* We need to do this before piping to handle some really
pathological cases where one of the pipe file descript
Pierre