Getting the terminal while in the background.
Pierre A. Humblet
Mon Oct 4 19:11:00 GMT 2004
Chet Ramey wrote:
> > Under Cygwin, the command below gives rise to a warning:
> > ~: true | `echo true` &
> >  380723
> > ~: Use "logout" to leave the shell.
> > + 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.
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
More information about the Cygwin-developers