Merge lp:~voldyman/pantheon-terminal/fixed-999981 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Akshay Shekher
Status: Merged
Approved by: David Gomes
Approved revision: 245
Merged at revision: 245
Proposed branch: lp:~voldyman/pantheon-terminal/fixed-999981
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 87 lines (+29/-6)
2 files modified
src/PantheonTerminalWindow.vala (+2/-0)
src/TerminalWidget.vala (+27/-6)
To merge this branch: bzr merge lp:~voldyman/pantheon-terminal/fixed-999981
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+114817@code.launchpad.net

Description of the change

kill child process (bash) and its children when the tab is closed.

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

try to use something like "bool try_get_foreground_process (out int pid)" instead of getting the pid twice

242. By Akshay Shekher

foreground pid is fetched only once.

243. By Akshay Shekher

kill bash and foreground process

244. By Akshay Shekher

Neatness check

245. By Akshay Shekher

Even more neatness

Revision history for this message
David Gomes (davidgomes) wrote :

Approved, nice job.

review: Approve

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 2012-07-13 10:43:10 +0000
3+++ src/PantheonTerminalWindow.vala 2012-07-13 11:49:25 +0000
4@@ -247,12 +247,14 @@
5 var d = new ForegroundProcessDialog ();
6 if (d.run () == 1) {
7 notebook.remove (g);
8+ t.kill_ps_and_fg ();
9 terminals.remove (t);
10 }
11 d.destroy ();
12 }
13 else {
14 notebook.remove (g);
15+ t.kill_ps ();
16 terminals.remove (t);
17 }
18 });
19
20=== modified file 'src/TerminalWidget.vala'
21--- src/TerminalWidget.vala 2012-05-17 18:29:15 +0000
22+++ src/TerminalWidget.vala 2012-07-13 11:49:25 +0000
23@@ -25,7 +25,6 @@
24 public class TerminalWidget : Vte.Terminal {
25
26 GLib.Pid child_pid;
27-
28 private PantheonTerminalWindow window;
29 public TerminalTab tab;
30
31@@ -53,10 +52,20 @@
32
33 /* Connect to necessary signals */
34 child_exited.connect (on_child_exited);
35-
36 }
37
38 void on_child_exited () { }
39+
40+ public void kill_ps () {
41+ Posix.kill (this.child_pid, 9);
42+ }
43+
44+ public void kill_ps_and_fg () {
45+ int fg_pid;
46+ if (this.try_get_foreground_pid (out fg_pid))
47+ Posix.kill (fg_pid, 9);
48+ kill_ps ();
49+ }
50
51 public void active_shell (string dir = GLib.Environment.get_current_dir ()) {
52 try {
53@@ -66,12 +75,24 @@
54 }
55 }
56
57+ public bool try_get_foreground_pid (out int pid) {
58+ int pty = this.pty_object.fd;
59+ int fgpid = Posix.tcgetpgrp (pty);
60+ if (fgpid != this.child_pid && fgpid != -1) {
61+ pid = (int) fgpid;
62+ return true;
63+ }
64+ else {
65+ pid = -1;
66+ return false;
67+ }
68+ }
69+
70 public bool has_foreground_process () {
71- int pty = this.pty_object.fd;
72- int fgpid = Posix.tcgetpgrp(pty);
73- return fgpid != this.child_pid && fgpid != -1;
74+ return try_get_foreground_pid (null);
75 }
76
77+
78 public int calculate_width (int column_count) {
79 return (int) (this.get_char_width()) * column_count;
80 }
81@@ -86,4 +107,4 @@
82
83 }
84
85-}
86+}
87\ No newline at end of file

Subscribers

People subscribed via source and target branches