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.