Merge lp:~thomas-voss/unity-mir/refactor-process-group-operations-to-rely-on-process-cpp into lp:unity-mir

Proposed by Thomas Voß
Status: Rejected
Rejected by: Gerry Boland
Proposed branch: lp:~thomas-voss/unity-mir/refactor-process-group-operations-to-rely-on-process-cpp
Merge into: lp:unity-mir
Prerequisite: lp:~thomas-voss/unity-mir/refactor-oom-score-adj-to-rely-on-process-cpp
Diff against target: 138 lines (+63/-29)
1 file modified
src/modules/Unity/Application/taskcontroller.cpp (+63/-29)
To merge this branch: bzr merge lp:~thomas-voss/unity-mir/refactor-process-group-operations-to-rely-on-process-cpp
Reviewer Review Type Date Requested Status
Gerry Boland (community) Disapprove
PS Jenkins bot (community) continuous-integration Needs Fixing
Michał Sawicz Needs Fixing
Review via email: mp+194804@code.launchpad.net

Commit message

Refactor sigstop'ing and sigcont'ing of application process groups to rely on process-cpp.

Description of the change

Refactor sigstop'ing and sigcont'ing of application process groups to rely on process-cpp.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
145. By Thomas Voß

Adjust to namespace core.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
146. By Thomas Voß

Mergeing.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
147. By Thomas Voß

[ Gerry Boland ]
* Unity.Application is not a shared library, but a plugin. (LP:
  #1256014)
* Implement preStart callback added to upstart-app-launch-2. (LP:
  #1243665)
[ Ubuntu daily release ]
* Automatic snapshot from revision 157
[ Gerry Boland ]
* Install ServerStatusListener to be notified of mir server start, pause
  and resume. Use start notification to send SIGSTOP signal to upstart,
  so it knows mir is ready for other clients.
* Bump version number
* InputArea: don't use lambda function as slot, can cause crash on
  shutdown Using lambda function as slot can introduce crash as the
  slot's object deletion is not registered unlike with traditional
  signal/slot connections. As a result, on signal emission, the lambda
  can be called on a deleted object. (LP: #1253685)
* Misc fixes for Mir 0.1.2 support. (LP: #1254986)
[ Alan Griffiths ]
* ApplicationSession is a Mir implementation class that shouldn't be
  used by unity-mir, use shell::session instead.
[ Kevin Gunn ]
* mir server abi and api broke, updating dependency to deb 0.1.1.
* update mir deb build dep to 0.1.2
[ Victor Thompson ]
* Fix mir to not suspend the music-app, or any other app granted a
  lifecycle exception, when switching between apps. (LP: #1241185,
  #1241045)
[ Daniel van Vugt ]
* Force the screen to redraw after turning the display back on (LP:
  #1255045). Also stop the compositor when the screen is off.
  Otherwise it will spin in the background, eating battery. (LP:
  #1255045)
[ Ubuntu daily release ]
* Automatic snapshot from revision 154
* Cherry-pick upstream patch to avoid Unity8 crashing on stop
  (LP: #1253685)
[ Gerry Boland ]
* On MirSurface destruction, any InputAreas on that surface will be
  notified and remove their links to that surface. Fixes crash
  bug:1243444. (LP: #1243444)
[ Alan Griffiths ]
* Remove dependency on mir::shell::SessionManager.
* Remove dependency on mir::surfaces::SurfaceController.
* Remove dependency on msh::OrganisingSurfaceFactory.
* Avoid relying on an explicit Mir typename that changes in a
  refactoring coming soon.
* Do all the hacky surface creation customization in
  SurfaceFactory::create_surface() - and don't mention SurfaceBuilder
  at all. (That will allow Mir to get rid of that interface.).
[ Albert Astals ]
* Don't include the QtQml megaheader Include the one we really need.
[ Ubuntu daily release ]
* Automatic snapshot from revision 144

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

"We do assume" → "We assume"

What's the reason to initialise process with invalid? Doesn't seem like it'd ever be accessed if invalid anyway?

Here, too, feels like it'd be a good time to start auto-testing this.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Is this MR still relevant?

review: Needs Information
Revision history for this message
Gerry Boland (gerboland) wrote :

Rejecting as is obsolete

review: Disapprove

Unmerged revisions

147. By Thomas Voß

[ Gerry Boland ]
* Unity.Application is not a shared library, but a plugin. (LP:
  #1256014)
* Implement preStart callback added to upstart-app-launch-2. (LP:
  #1243665)
[ Ubuntu daily release ]
* Automatic snapshot from revision 157
[ Gerry Boland ]
* Install ServerStatusListener to be notified of mir server start, pause
  and resume. Use start notification to send SIGSTOP signal to upstart,
  so it knows mir is ready for other clients.
* Bump version number
* InputArea: don't use lambda function as slot, can cause crash on
  shutdown Using lambda function as slot can introduce crash as the
  slot's object deletion is not registered unlike with traditional
  signal/slot connections. As a result, on signal emission, the lambda
  can be called on a deleted object. (LP: #1253685)
* Misc fixes for Mir 0.1.2 support. (LP: #1254986)
[ Alan Griffiths ]
* ApplicationSession is a Mir implementation class that shouldn't be
  used by unity-mir, use shell::session instead.
[ Kevin Gunn ]
* mir server abi and api broke, updating dependency to deb 0.1.1.
* update mir deb build dep to 0.1.2
[ Victor Thompson ]
* Fix mir to not suspend the music-app, or any other app granted a
  lifecycle exception, when switching between apps. (LP: #1241185,
  #1241045)
[ Daniel van Vugt ]
* Force the screen to redraw after turning the display back on (LP:
  #1255045). Also stop the compositor when the screen is off.
  Otherwise it will spin in the background, eating battery. (LP:
  #1255045)
[ Ubuntu daily release ]
* Automatic snapshot from revision 154
* Cherry-pick upstream patch to avoid Unity8 crashing on stop
  (LP: #1253685)
[ Gerry Boland ]
* On MirSurface destruction, any InputAreas on that surface will be
  notified and remove their links to that surface. Fixes crash
  bug:1243444. (LP: #1243444)
[ Alan Griffiths ]
* Remove dependency on mir::shell::SessionManager.
* Remove dependency on mir::surfaces::SurfaceController.
* Remove dependency on msh::OrganisingSurfaceFactory.
* Avoid relying on an explicit Mir typename that changes in a
  refactoring coming soon.
* Do all the hacky surface creation customization in
  SurfaceFactory::create_surface() - and don't mention SurfaceBuilder
  at all. (That will allow Mir to get rid of that interface.).
[ Albert Astals ]
* Don't include the QtQml megaheader Include the one we really need.
[ Ubuntu daily release ]
* Automatic snapshot from revision 144

146. By Thomas Voß

Mergeing.

145. By Thomas Voß

Adjust to namespace core.

144. By Thomas Voß

Refactor sigstop'ing and sigcont'ing of application process groups to rely on process-cpp.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/taskcontroller.cpp'
2--- src/modules/Unity/Application/taskcontroller.cpp 2013-12-09 16:39:29 +0000
3+++ src/modules/Unity/Application/taskcontroller.cpp 2013-12-09 16:39:29 +0000
4@@ -45,14 +45,12 @@
5
6 namespace
7 {
8-void ensureProcessIsUnlikelyToBeKilled(pid_t pid)
9+void ensureProcessIsUnlikelyToBeKilled(core::posix::Process process)
10 {
11 // By system default, we set the oom_score_adj of Unity8 to -10 (via lightdm).
12 // As we want to avoid that any app's oom_score_adj is <= Unity8's oom_score_adj,
13 // we choose a default increase of +1.
14 static const int default_increase = 1;
15-
16- core::posix::Process process(pid);
17
18 try
19 {
20@@ -84,14 +82,12 @@
21 }
22 }
23
24-void ensureProcessIsLikelyToBeKilled(pid_t pid)
25+void ensureProcessIsLikelyToBeKilled(core::posix::Process process)
26 {
27 // We avoid extremal values for oom_score_adj. For that, we
28 // set it to 80% of the total available range.
29 static const float defaultPercentage = 0.8;
30
31- core::posix::Process process(pid);
32-
33 try
34 {
35 plpp::OomScoreAdj shellScore;
36@@ -150,7 +146,15 @@
37 focusCallback = [](const gchar * appId, gpointer userData) {
38 Q_UNUSED(userData)
39 pid_t pid = upstart_app_launch_get_primary_pid(appId);
40- ensureProcessIsUnlikelyToBeKilled(pid);
41+
42+ try
43+ {
44+ ensureProcessIsUnlikelyToBeKilled(core::posix::Process{pid});
45+ } catch(const std::runtime_error&)
46+ {
47+ LOG("TaskController::startCallback: pid queried from upstart app launch is invalid.");
48+ }
49+
50 Q_EMIT TaskController::singleton()->requestFocus(QString(appId));
51 };
52
53@@ -232,17 +236,32 @@
54 DLOG("TaskController::suspend (this=%p, application=%p)", this, qPrintable(appId));
55 pid_t pid = upstart_app_launch_get_primary_pid(appId.toLatin1().constData());
56
57- ensureProcessIsLikelyToBeKilled(pid);
58-
59- if (pid) {
60- // We do assume that the app was launched by upstart and with that,
61- // in its own process group. For that, we interpret the pid as pgid and
62- // sigstop the complete process group on suspend.
63- kill(-pid, SIGSTOP);
64- return true;
65- } else {
66- return false;
67- }
68+ core::posix::Process process = core::posix::Process::invalid();
69+ try
70+ {
71+ process = core::posix::Process{pid};
72+ } catch(const std::runtime_error&)
73+ {
74+ // If the pid reported by upstart app launch is invalid, we error out here.
75+ LOG("TaskController::suspend: pid queried from upstart app launch is invalid.");
76+ return false;
77+ }
78+
79+ ensureProcessIsLikelyToBeKilled(process);
80+
81+ // We do assume that the app was launched by upstart and with that,
82+ // in its own process group.
83+ try
84+ {
85+ auto pg = process.process_group_or_throw();
86+ pg.send_signal_or_throw(core::posix::Signal::sig_stop);
87+ } catch(const std::system_error& e)
88+ {
89+ LOG("TaskController::suspend: Exception sig-stop'ing process group (%s)", e.what());
90+ return false;
91+ }
92+
93+ return true;
94 }
95
96 bool TaskController::resume(const QString& appId)
97@@ -250,15 +269,30 @@
98 DLOG("TaskController::resume (this=%p, application=%p)", this, qPrintable(appId));
99 pid_t pid = upstart_app_launch_get_primary_pid(appId.toLatin1().constData());
100
101- ensureProcessIsUnlikelyToBeKilled(pid);
102-
103- if (pid) {
104- // We do assume that the app was launched by upstart and with that,
105- // in its own process group. For that, we interpret the pid as pgid and
106- // sigcont the complete process group on resume.
107- kill(-pid, SIGCONT);
108- return true;
109- } else {
110- return false;
111- }
112+ core::posix::Process process = core::posix::Process::invalid();
113+ try
114+ {
115+ process = core::posix::Process{pid};
116+ } catch(const std::runtime_error&)
117+ {
118+ // If the pid reported by upstart app launch is invalid, we error out here.
119+ LOG("TaskController::resume: pid queried from upstart app launch is invalid.");
120+ return false;
121+ }
122+
123+ ensureProcessIsUnlikelyToBeKilled(process);
124+
125+ // We do assume that the app was launched by upstart and with that,
126+ // in its own process group.
127+ try
128+ {
129+ auto pg = process.process_group_or_throw();
130+ pg.send_signal_or_throw(core::posix::Signal::sig_cont);
131+ } catch(const std::system_error& e)
132+ {
133+ LOG("TaskController::resume: Exception sig-continue'ing process group (%s)", e.what());
134+ return false;
135+ }
136+
137+ return true;
138 }

Subscribers

People subscribed via source and target branches