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


Andy Koppe:
> 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 SIGHUP in these cases.

Ah, it's due to a bash option: huponexit, which is off by default.
When bash receives a SIGHUP, e.g. due to the terminal's close button
being pressed, it always forwards that to its children (apart from
those that have been disowned). But when exiting bash, it only sends
SIGHUP if huponexit is set. Bash's children don't directly receive
SIGHUPs from the terminal, because each is placed into a separate
process group.

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]