Opened 16 years ago
Closed 14 years ago
#3745 closed enhancement (fixed)
Preferences : "[x] Warn upon closing active programs"
Reported by: | mmadia | Owned by: | jackburton |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Applications/Terminal | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Considering that Terminal supports tabbed windows, should we add an option that can warn the user that by closing Terminal, they are about to forcefully abort running programs in other tabs?
I'm hesitant to suggest this as default behavior, even though it parallels other programs. As an example, StyledEdit ask for confirmation to save an unsaved work when closing.
Maybe the default behavior can be to simply prevent Terminal from closing when a program is running. Instead, Terminal can flash those tabs as an indicator of sorts.
Change History (11)
comment:1 by , 16 years ago
follow-up: 3 comment:2 by , 14 years ago
In theory "waitpid(-1, &status, WNOHANG)" should tell if a child process has exited or not, and thus be used to tell if a program is still running. In practice, I've experimented with it a bit, but there seems to be no difference in the returned values. Maybe since "bash" is already a child process, waitpid() will always return that there are still child processes runing.
follow-up: 4 comment:3 by , 14 years ago
Replying to jackburton:
In theory "waitpid(-1, &status, WNOHANG)" should tell if a child process has exited or not, and thus be used to tell if a program is still running. In practice, I've experimented with it a bit, but there seems to be no difference in the returned values. Maybe since "bash" is already a child process, waitpid() will always return that there are still child processes runing.
Maybe I misunderstand what you're saying. waitpid() does not tell you whether there are still living children. It does only tell you about terminated children. I don't see what this has to do with this ticket, though. Isn't this just about checking whether number of tabs > 1 before quitting?
follow-up: 5 comment:4 by , 14 years ago
Replying to bonefish:
Maybe I misunderstand what you're saying. waitpid() does not tell you whether there are still living children. It does only tell you about terminated children. I don't see what this has to do with this ticket, though. Isn't this just about checking whether number of tabs > 1 before quitting?
More useful would be what the Gnome Terminal do. If you have an active program executed in the shell (for example, a ssh or telnet session), it warns you (on close) that there is something active. I thought waitpid() could be used to check that, but I probably misread the documentation.
follow-up: 6 comment:5 by , 14 years ago
Replying to jackburton:
More useful would be what the Gnome Terminal do. If you have an active program executed in the shell (for example, a ssh or telnet session), it warns you (on close) that there is something active.
Not sure whether that's always what one would want, but I guess it's probably the least annoying while protecting programs from being killed by accident.
I thought waitpid() could be used to check that, but I probably misread the documentation.
You might be interested in tcgetpgrp(). If the terminal's foreground group is not the shell, then something else is actively running. That doesn't catch stopped or background jobs, though. You could test what Gnome Terminal does in these situations. Well, or look in its source code. It might make use of procfs, though, which we don't have.
follow-up: 8 comment:6 by , 14 years ago
Replying to bonefish:
You might be interested in tcgetpgrp(). If the terminal's foreground group is not the shell, then something else is actively running.
Ah yes, that works well. Thanks!
That doesn't catch stopped or background jobs, though.
I see.
You could test what Gnome Terminal does in these situations. Well, or look in its source code. It might make use of procfs, though, which we don't have.
I just tested on the opensuse 11.0 I have here, and Terminal doesn't ask anything on exit, not even if there are active children. On the Ubuntu 10.4 I have at home, though, it does. So I guess it depends on how it's compiled. Will test it later.
follow-up: 9 comment:7 by , 14 years ago
I added this functionality in hrev37755, although you get the warning only if you close the window (not the single tab).
comment:8 by , 14 years ago
Replying to jackburton:
I just tested on the opensuse 11.0 I have here, and Terminal doesn't ask anything on exit, not even if there are active children. On the Ubuntu 10.4 I have at home, though, it does.
Neither keep track of background jobs.
comment:9 by , 14 years ago
Replying to jackburton:
I added this functionality in hrev37755, although you get the warning only if you close the window (not the single tab).
By the way: The preference is currently called "Warn on Exit", although it isn't correct. You suggested "Warn upon closing active programs", but I'm not really sure about it (but I'm not a native english speaker, so if no one else comes up with a better sentence, I guess I'll use that one).
comment:11 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
One possible solution would be to just ask a confirmation when you want to quit terminal and there is more than one tab open, running programs or not.
Additionnally, there could be a "don't nag me with this anymore" checkbox..