Merge lp:~niclasl/pantheon-terminal/fix-1327526 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Niclas Lockner
Status: Merged
Approved by: Raphael Isemann
Approved revision: 595
Merged at revision: 592
Proposed branch: lp:~niclasl/pantheon-terminal/fix-1327526
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 59 lines (+12/-10)
2 files modified
src/PantheonTerminalWindow.vala (+7/-4)
src/TerminalWidget.vala (+5/-6)
To merge this branch: bzr merge lp:~niclasl/pantheon-terminal/fix-1327526
Reviewer Review Type Date Requested Status
Raphael Isemann (community) code and functionality Approve
Sergey "Shnatsel" Davidoff (community) Approve
Review via email: mp+229307@code.launchpad.net

Commit message

Fixed shutdown when the user cancels the dialog as described in #1327526

Description of the change

1. Wait with the shell termination until all dialog windows has been processed and it is known that the window will close

2. Retry to terminate the shell as long as it hasn't terminated (Fixes an issue where the shell didn't terminate when kill_fg_and_term_ps was called)

To post a comment you must log in.
592. By Niclas Lockner

Avoid a possible endless loop when terminating the shell

Revision history for this message
Raphael Isemann (teemperor) wrote :

Fixes said bug and the rest still works. Code-style is correct too.

The thing that bugs me is the loop at the end:

1.
Posix.usleep (100);
is also available in the GLib via
GLib.Thread.usleep (100);

2. I those lines should to be the other way round, as we first should send a signal and then wait.

Posix.usleep (100);
Posix.kill (this.child_pid, Posix.SIGTERM);

3. This
Posix.kill (this.child_pid, 0) != -1
can be
Posix.kill (this.child_pid, 0) == 0
on both occurrences.

Also a comment like
// Check if PID is valid
should be added as it's not that obvious what kill with sig 0 does.

4. I think we shouldn't SIGKILL here, but not sure what we should do instead. Let's add shnatsel and see what his opinion is on this topic.

Posix.kill (this.child_pid, Posix.SIGKILL);

review: Needs Fixing (code and functionality)
Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

Do not sigkill without a good reason! An illustration of proper use of sigkill can be seen in window managers for unresponsive applications, I believe you should just mirror that.

593. By Niclas Lockner

Revert to not kill the shell

594. By Niclas Lockner

Remove unused variable

Revision history for this message
Raphael Isemann (teemperor) wrote :

Oh, line 46 in the diff, the first

Posix.kill (this.child_pid, Posix.SIGTERM);

is unecessary.

review: Needs Fixing
595. By Niclas Lockner

Remove redundant kill call

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

Fine with me for now. Just document the potential issue with infinite loop in the end in a new bug report and go ahead. Thanks!

review: Approve
Revision history for this message
Raphael Isemann (teemperor) wrote :

Ok, i'm fine with it too.

The problem is now in a extra-bugreport: https://bugs.launchpad.net/pantheon-terminal/+bug/1353159

review: Approve (code and functionality)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PantheonTerminalWindow.vala'
2--- src/PantheonTerminalWindow.vala 2014-08-01 21:31:33 +0000
3+++ src/PantheonTerminalWindow.vala 2014-08-05 20:58:53 +0000
4@@ -524,6 +524,7 @@
5 update_saved_window_state ();
6 action_quit ();
7 string tabs = "";
8+ var tabs_to_terminate = new GLib.List <TerminalWidget> ();
9
10 foreach (var t in terminals) {
11 t = (TerminalWidget) t;
12@@ -531,18 +532,20 @@
13 if (t.has_foreground_process ()) {
14 var d = new ForegroundProcessDialog.before_close ();
15 if (d.run () == 1) {
16- t.kill_fg_and_term_ps ();
17+ t.kill_fg ();
18 d.destroy ();
19 } else {
20 d.destroy ();
21 return true;
22 }
23-
24- } else {
25- t.term_ps ();
26 }
27+
28+ tabs_to_terminate.append (t);
29 }
30
31+ foreach (var t in tabs_to_terminate)
32+ t.term_ps ();
33+
34 saved_state.tabs = tabs;
35 return false;
36 }
37
38=== modified file 'src/TerminalWidget.vala'
39--- src/TerminalWidget.vala 2014-08-05 18:12:39 +0000
40+++ src/TerminalWidget.vala 2014-08-05 20:58:53 +0000
41@@ -242,13 +242,12 @@
42
43 public void term_ps () {
44 killed = true;
45- //this.pty_object.close ();
46- Posix.kill (this.child_pid, Posix.SIGTERM);
47- }
48
49- public void kill_fg_and_term_ps () {
50- kill_fg ();
51- term_ps ();
52+ /* Check if the shell process is still alive by sending 0 signals */
53+ while (Posix.kill (this.child_pid, 0) == 0) {
54+ Posix.kill (this.child_pid, Posix.SIGTERM);
55+ Thread.usleep (100);
56+ }
57 }
58
59 public void active_shell (string dir = GLib.Environment.get_current_dir ()) {

Subscribers

People subscribed via source and target branches