public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Background processes prevent terminal window from closing
@ 2011-05-05  4:30 Ryan Dortmans
  2011-05-05  4:43 ` Andy Koppe
  2011-05-05 11:38 ` Buchbinder, Barry (NIH/NIAID) [E]
  0 siblings, 2 replies; 4+ messages in thread
From: Ryan Dortmans @ 2011-05-05  4:30 UTC (permalink / raw)
  To: cygwin

Hi,

I have found that background processes prevent the terminal window
from closing. I have tried with the cmd terminal as well as mintty.
Here is a simple example:

$ notepad .profile &
[1] 10260
$ exit
logout

The window remains until I close the notepad window. I have also
reproduced the issue using a simple looping shell script instead of a
windows program.

I thought that running disown would detach the process to turn it into
a daemon, but this has no effect.

Is there any way to detach running background processes such that the
terminal can be closed?

Cheers,

Ryan Dortmans

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Background processes prevent terminal window from closing
  2011-05-05  4:30 Background processes prevent terminal window from closing Ryan Dortmans
@ 2011-05-05  4:43 ` Andy Koppe
  2011-05-05 11:38 ` Buchbinder, Barry (NIH/NIAID) [E]
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Koppe @ 2011-05-05  4:43 UTC (permalink / raw)
  To: cygwin

On 5 May 2011 05:30, Ryan Dortmans wrote:
> Hi,
>
> I have found that background processes prevent the terminal window
> from closing. I have tried with the cmd terminal as well as mintty.
> Here is a simple example:
>
> $ notepad .profile &
> [1] 10260
> $ exit
> logout
>
> The window remains until I close the notepad window. I have also
> reproduced the issue using a simple looping shell script instead of a
> windows program.
>
> I thought that running disown would detach the process to turn it into
> a daemon, but this has no effect.

No, this just removes it from the shell's job control, but it still
remains connected to the terminal session.

> Is there any way to detach running background processes such that the
> terminal can be closed?

You can start a program in a separate session using the 'setsid'
utility from the util-linux package. I don't know whether it's
possible to detach a running process.

You can close the terminal anyway though using the Close button (or
Alt+F4 in the case of mintty), except of course that the background
process might also be closed, depending on its SIGHUP handling.

Andy

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Background processes prevent terminal window from closing
  2011-05-05  4:30 Background processes prevent terminal window from closing Ryan Dortmans
  2011-05-05  4:43 ` Andy Koppe
@ 2011-05-05 11:38 ` Buchbinder, Barry (NIH/NIAID) [E]
  2011-05-05 13:23   ` Charles Wilson
  1 sibling, 1 reply; 4+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) [E] @ 2011-05-05 11:38 UTC (permalink / raw)
  To: cygwin, 'Ryan Dortmans'

Ryan Dortmans sent the following at Thursday, May 05, 2011 12:30 AM
>I have found that background processes prevent the terminal window from
>closing. I have tried with the cmd terminal as well as mintty. Here is a
>simple example:
>
>$ notepad .profile &
>[1]
>10260
>$ exit
>logout
>
>The window remains until I close the notepad window. I have also
>reproduced the issue using a simple looping shell script instead of a
>windows program.
>
>I thought that running disown would detach the process to turn it into a
>daemon, but this has no effect.
>
>Is there any way to detach running background processes such that the
>terminal can be closed?

Why not use cygstart to launch it already "detached"?

You might create the following alias in your profile or .bashrc.

alias notepad="cygstart '$(cygpath -u -W)/notepad.exe'"

But if you do not want to be limited file in the current working
directory, use a function.

notepad ()
{
    cygstart "$(cygpath -u -W)/notepad.exe" "$(cygpath -w "$1")"
}

You might have to change -W to -S in the first cygpath, if notepad.exe
is in $SYSDIR but not WINDIR.  (In my instance of XP, it is in both.)

Best wishes,

- Barry
  Disclaimer: Statements made herein are not made on behalf of NIAID.



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Background processes prevent terminal window from closing
  2011-05-05 11:38 ` Buchbinder, Barry (NIH/NIAID) [E]
@ 2011-05-05 13:23   ` Charles Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Charles Wilson @ 2011-05-05 13:23 UTC (permalink / raw)
  To: cygwin

On 5/5/2011 7:38 AM, Buchbinder, Barry (NIH/NIAID) [E] wrote:
> But if you do not want to be limited file in the current working
> directory, use a function.
> 
> notepad ()
> {
>     cygstart "$(cygpath -u -W)/notepad.exe" "$(cygpath -w "$1")"
> }
> 
> You might have to change -W to -S in the first cygpath, if notepad.exe
> is in $SYSDIR but not WINDIR.  (In my instance of XP, it is in both.)

the latest (1.4.6) version of cygstart should allow the following to work:

notepad ()
{
    cygstart notepad.exe "$(cygpath -w "$1")"
}

--
Chuck

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-05 13:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05  4:30 Background processes prevent terminal window from closing Ryan Dortmans
2011-05-05  4:43 ` Andy Koppe
2011-05-05 11:38 ` Buchbinder, Barry (NIH/NIAID) [E]
2011-05-05 13:23   ` Charles Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).