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
=== modified file 'src/modules/Unity/Application/taskcontroller.cpp'
--- src/modules/Unity/Application/taskcontroller.cpp 2013-12-09 16:39:29 +0000
+++ src/modules/Unity/Application/taskcontroller.cpp 2013-12-09 16:39:29 +0000
@@ -45,14 +45,12 @@
4545
46namespace46namespace
47{47{
48void ensureProcessIsUnlikelyToBeKilled(pid_t pid)48void ensureProcessIsUnlikelyToBeKilled(core::posix::Process process)
49{49{
50 // By system default, we set the oom_score_adj of Unity8 to -10 (via lightdm).50 // By system default, we set the oom_score_adj of Unity8 to -10 (via lightdm).
51 // As we want to avoid that any app's oom_score_adj is <= Unity8's oom_score_adj,51 // As we want to avoid that any app's oom_score_adj is <= Unity8's oom_score_adj,
52 // we choose a default increase of +1.52 // we choose a default increase of +1.
53 static const int default_increase = 1;53 static const int default_increase = 1;
54
55 core::posix::Process process(pid);
5654
57 try55 try
58 {56 {
@@ -84,14 +82,12 @@
84 }82 }
85}83}
8684
87void ensureProcessIsLikelyToBeKilled(pid_t pid)85void ensureProcessIsLikelyToBeKilled(core::posix::Process process)
88{86{
89 // We avoid extremal values for oom_score_adj. For that, we87 // We avoid extremal values for oom_score_adj. For that, we
90 // set it to 80% of the total available range.88 // set it to 80% of the total available range.
91 static const float defaultPercentage = 0.8;89 static const float defaultPercentage = 0.8;
9290
93 core::posix::Process process(pid);
94
95 try91 try
96 {92 {
97 plpp::OomScoreAdj shellScore;93 plpp::OomScoreAdj shellScore;
@@ -150,7 +146,15 @@
150 focusCallback = [](const gchar * appId, gpointer userData) {146 focusCallback = [](const gchar * appId, gpointer userData) {
151 Q_UNUSED(userData)147 Q_UNUSED(userData)
152 pid_t pid = upstart_app_launch_get_primary_pid(appId);148 pid_t pid = upstart_app_launch_get_primary_pid(appId);
153 ensureProcessIsUnlikelyToBeKilled(pid);149
150 try
151 {
152 ensureProcessIsUnlikelyToBeKilled(core::posix::Process{pid});
153 } catch(const std::runtime_error&)
154 {
155 LOG("TaskController::startCallback: pid queried from upstart app launch is invalid.");
156 }
157
154 Q_EMIT TaskController::singleton()->requestFocus(QString(appId));158 Q_EMIT TaskController::singleton()->requestFocus(QString(appId));
155 };159 };
156160
@@ -232,17 +236,32 @@
232 DLOG("TaskController::suspend (this=%p, application=%p)", this, qPrintable(appId));236 DLOG("TaskController::suspend (this=%p, application=%p)", this, qPrintable(appId));
233 pid_t pid = upstart_app_launch_get_primary_pid(appId.toLatin1().constData());237 pid_t pid = upstart_app_launch_get_primary_pid(appId.toLatin1().constData());
234238
235 ensureProcessIsLikelyToBeKilled(pid);239 core::posix::Process process = core::posix::Process::invalid();
236240 try
237 if (pid) {241 {
238 // We do assume that the app was launched by upstart and with that,242 process = core::posix::Process{pid};
239 // in its own process group. For that, we interpret the pid as pgid and243 } catch(const std::runtime_error&)
240 // sigstop the complete process group on suspend.244 {
241 kill(-pid, SIGSTOP);245 // If the pid reported by upstart app launch is invalid, we error out here.
242 return true;246 LOG("TaskController::suspend: pid queried from upstart app launch is invalid.");
243 } else {247 return false;
244 return false;248 }
245 }249
250 ensureProcessIsLikelyToBeKilled(process);
251
252 // We do assume that the app was launched by upstart and with that,
253 // in its own process group.
254 try
255 {
256 auto pg = process.process_group_or_throw();
257 pg.send_signal_or_throw(core::posix::Signal::sig_stop);
258 } catch(const std::system_error& e)
259 {
260 LOG("TaskController::suspend: Exception sig-stop'ing process group (%s)", e.what());
261 return false;
262 }
263
264 return true;
246}265}
247266
248bool TaskController::resume(const QString& appId)267bool TaskController::resume(const QString& appId)
@@ -250,15 +269,30 @@
250 DLOG("TaskController::resume (this=%p, application=%p)", this, qPrintable(appId));269 DLOG("TaskController::resume (this=%p, application=%p)", this, qPrintable(appId));
251 pid_t pid = upstart_app_launch_get_primary_pid(appId.toLatin1().constData());270 pid_t pid = upstart_app_launch_get_primary_pid(appId.toLatin1().constData());
252271
253 ensureProcessIsUnlikelyToBeKilled(pid);272 core::posix::Process process = core::posix::Process::invalid();
254273 try
255 if (pid) {274 {
256 // We do assume that the app was launched by upstart and with that,275 process = core::posix::Process{pid};
257 // in its own process group. For that, we interpret the pid as pgid and276 } catch(const std::runtime_error&)
258 // sigcont the complete process group on resume.277 {
259 kill(-pid, SIGCONT);278 // If the pid reported by upstart app launch is invalid, we error out here.
260 return true;279 LOG("TaskController::resume: pid queried from upstart app launch is invalid.");
261 } else {280 return false;
262 return false;281 }
263 }282
283 ensureProcessIsUnlikelyToBeKilled(process);
284
285 // We do assume that the app was launched by upstart and with that,
286 // in its own process group.
287 try
288 {
289 auto pg = process.process_group_or_throw();
290 pg.send_signal_or_throw(core::posix::Signal::sig_cont);
291 } catch(const std::system_error& e)
292 {
293 LOG("TaskController::resume: Exception sig-continue'ing process group (%s)", e.what());
294 return false;
295 }
296
297 return true;
264}298}

Subscribers

People subscribed via source and target branches