Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The following simple command should demonstrate my issue:

gnome-terminal --tab -t "Tab 1" -e "/bin/bash" --tab -t "Tab 2" -e "/bin/bash"

This should open a new window with two tabs and an active bash shell. If I immediately close this new window using the GUI [x] and then execute a ps command, one (in this case) sub process (/bin/bash) will be left open.

I have found out that this corresponds to all inactive tabs that have never been made active (by clicking on them) at some point in time. So if we crafted a new command similar to the example above but with 5 tabs instead of 2 and you immediately closed this window after running the command, 4 sub-processes will be left running.

Here is the peculiar part...if you click on each tab to make it active and then close the window, all of the sub-processes will be killed, as one would expect.

Is this a bug in gnome-terminal?

How can I ensure these processes are closed and not left open?

After further investigation it appears that the parent process ID of the process(es) left open is the PID of the terminal from which the command above is executed. I would expect that closing the newly spawned window would be enough to kill the sub-processes corresponding to each tab (regardless of whether it has been made active or not), not having to kill the original, source terminal. Hope that made sense.

share|improve this question
    
0 down vote Bash does not send the nohup signal to its background children upon normal exit. The terminal probably keeps the shells in the background before they are clicked. See askubuntu.com/q/249747/80864 and its answers and comments. –  choroba Aug 1 '13 at 20:19
    
Is there any way to get around that limitation? Like somehow bringing each inactive tab's process to the foreground programatically? –  Joe Aug 1 '13 at 21:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.