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 stpere, 16 years ago

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..

comment:2 by jackburton, 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.

in reply to:  2 ; comment:3 by bonefish, 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?

in reply to:  3 ; comment:4 by jackburton, 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.

in reply to:  4 ; comment:5 by bonefish, 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.

in reply to:  5 ; comment:6 by jackburton, 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.

comment:7 by jackburton, 14 years ago

I added this functionality in hrev37755, although you get the warning only if you close the window (not the single tab).

in reply to:  6 comment:8 by jackburton, 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.

in reply to:  7 comment:9 by jackburton, 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:10 by jackburton, 14 years ago

Implemented the rest in hrev39329.

comment:11 by jackburton, 14 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.