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: service interact with desktop broken between: 1.5.5 & 1.5.19


On Mar 26 20:24, Lev Bishop wrote:
> Thanks, Corinna. I can almost get it working now. Maybe you can
> explain why this works:
> 
> $ cygrunsrv -I cygtest -jid 'cygrunsrv test' -p '/cygdrive/c/i386/cmd.exe' \
> -0/dev/console -1/dev/console -2/dev/console
> 
> Giving me a console running cmd.exe that I can, for example run bash in.
> Whereas it fails if I put -p '/bin/bash' directly for the command.
> 
> I experimented, and found that if I do the following:
> $ cygrunsrv -I cygtest -jid 'cygrunsrv test' -p '/bin/bash' -a $'-c "\
> echo this is on STDOUT;\
> echo this is on STDERR >&2;\
> ls -l /proc/self/fd;\
> read -p \'Give me something on STDIN: \' input;\
> echo input was $input " ' \
> -0/dev/console -1/dev/console -2/dev/console
> 
> Then I get a console window showing the messages to stdout and stderr,
> the /proc/self/fd listing confirms that fd0 is open on /dev/console,
> but the 'read' builtin hangs and doesn't read anything. So it looks
> like standard input isn't getting properly mapped in this case, even
> though stdout and stderr are.

That's a long-standing problem in cygrunsrv.  Child processes started
from cygrunsrv are put in their own process group, thus being background
processes.  This is usually correct, since the applications running as
services are usually daemon processes, and the stdio descriptors are
usually redirected to /dev/null or log files.

But in case of interactive processes which "redirect" their stdio
descriptors to the existing console as above that's not quite right.
Becoming a background process means for the child process hanging on
input and the foreground process gets a signal and has to care for that.
The foreground process here is cygrunsrv, but cygrunsrv doesn't care, so
the process remains in the stopped state.  The reason that this works
with cmd is that cmd simply doesn't care for POSIX rubbish like
controlling ttys or signals.

I've applied a fix to cygrunsrv and uploaded the new version 1.14-1.


Thanks for the above testcase,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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