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: terminals getting killed on parent's termination


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


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