terminals getting killed on parent's termination

Andy Koppe andy.koppe@gmail.com
Fri Feb 26 20:29:00 GMT 2010


Thomas Wolff wrote:
> In general, a GUI application started in the background, like a terminal,
> should detach itself from its parent process so that it survives if the
> parent is terminated.

Says who? You can always invoke it with setsid or some such to detach it.

> I've noticed the following sometimes surprising inconsistencies about this:
>
> mintty
>        xterm &
>        mintty &
>        Close/Alt-F4
>        -> dialog "Processes are running in session. Exit anyway?"
>        OK
>        -> xterm remains
>        -> mintty is killed
> xterm
>        xterm &
>        mintty &
>        Close/Quit
>        -> xterm remains
>        -> mintty is killed

Mintty has default handling for SIGHUP, i.e. it exits. Same for rxvt.
Xterm presumably chooses to ignore it.

> mintty
>        xterm &
>        mintty &
>        exit
>        -> all child terminals remain
> xterm
>        xterm &
>        mintty &
>        exit
>        -> all child terminals remain

I don't understand why there isn't a SIGUP in these cases.

> cygwin console
>        xterm &
>        mintty &
>        exit/Alt-F4
>        -> console hangs

It's not really hanging; it's just waiting for xterm to finish. Xterm
is linked as a console subsystem program, which means at startup it
attaches to its parent's console (or opens its own if there isn't
one). Consoles stay open as long as there's at least one process
attached to them.

Mintty, meanwhile, is a GUI subsystem program, which means it doesn't
attach to or open a console.

>        Close
>        -> mintty remains
>        -> xterm is killed

When a console is closed, Windows kills all processes attached to it.

> Also, mintty can be protected from being killed by spawning it with
> (mintty&)
> while xterm, spawned this way from a cygwin console, still gets killed.

Yep, doing that doesn't break the console attachment.

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



More information about the Cygwin mailing list