delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/03/27/10:21:39

X-Spam-Check-By: sourceware.org
Date: Mon, 27 Mar 2006 17:21:28 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: service interact with desktop broken between: 1.5.5 & 1.5.19
Message-ID: <20060327152128.GE20907@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <007e01c64de2$c95200a0$b3db87d4 AT multiplay DOT co DOT uk> <01ff01c64f42$079578f0$b3db87d4 AT multiplay DOT co DOT uk> <ba40711f0603250937u7b707c05ke60f42f09459b685 AT mail DOT gmail DOT com> <ba40711f0603251053i36715466nf8ae53ec11ac2096 AT mail DOT gmail DOT com> <20060326143235 DOT GW10301 AT calimero DOT vinschen DOT de> <ba40711f0603261724i5c597e6ei94e444bede744875 AT mail DOT gmail DOT com>
Mime-Version: 1.0
In-Reply-To: <ba40711f0603261724i5c597e6ei94e444bede744875@mail.gmail.com>
User-Agent: Mutt/1.4.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019