While using Konsole as my terminal emulator, I realized that in addition to typing exit
or hitting Ctrld, I can also click "close tab" and it closes it. What's interesting though is that sometimes it requires confirmation and sometimes it doesn't. For example, when I run "cat" and while it's running try to close the tab, I get an "are you sure?" dialog screen. But when it's at the terminal prompt, no such window gets open. How can the terminal emulator tell whether it's safe to simply close the window?
Asked
Active
Viewed 65 times
1

Stephen Kitt
- 434,908

d33tah
- 1,371
- 14
- 28
1 Answers
2
When you close a tab, Konsole checks whether a “foreground process” is active — whether the current foreground process in the tab’s session is not the session’s process group leader (which is the shell, for tabs which start by running a shell). Thus when you’re at the shell prompt, there’s no confirmation, even when “background” processes are running. When the tab is running something other than its process group leader in the foreground, Konsole asks for confirmation.
The same check runs when you close the whole window.

Stephen Kitt
- 434,908
top &
) and see if the warning also appears. In your shell, trypgrep -P $$
to check for child processes – Panki May 26 '22 at 13:34