This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem redirecting stderr to pipe in subprocess

On 10/8/2011 11:35 AM, Ken Brown wrote:
The attached STC arose from my attempt to understand the problem
discussed starting in .

I'm starting a new thread because there appears to be a Cygwin problem
having nothing to do with emacs.

The STC creates a pipe and then runs `bash -ic ls' in a subprocess, with
both stdout and stderr sent to the pipe. The parent process reads from
the pipe and echoes it to the terminal.

On Linux, I first get the error messages (presumably expected)

bash: cannot set terminal process group (-1): Invalid argument
bash: no job control in this shell

followed by the directory listing. On Cygwin, the bash process produces
no output but is simply stopped, and I have to kill it from another
terminal before the main program will exit. This happens both with
cygwin-1.7.9 and the latest snapshot. Here are a few comments:

1. The problem disappears if I don't send bash's stderr to the pipe.

2. The problem also disappears if I replace -ic by -c in the call to
bash, presumably because there's nothing sent to stderr in that case.

3. The problem disappears if I don't use a pipe but just have the bash
subprocess write to the terminal, even if I redirect bash's stderr to

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.


Attachment: bash-ls1.c
Description: Text document

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]