diff options
authorMartin Gräßlin <[email protected]>2017-04-23 10:27:09 +0200
committerMartin Gräßlin <[email protected]>2017-04-23 10:35:51 +0200
commitc5e49e466e48aef26c03d6c3784aabf94d52118d (patch)
parentcc3265cf01ccbfbb0ad14570e6f1cf2ffb9b9457 (diff)
Prevent kcheckpass from becoming an orphan
Summary: With the long running kcheckpass there is the possibility that kcheckpass becomes an orphan. Kcheckpass terminates once it gets SIGUSR2 sent from the parent process (that is kscreenlocker_greet). If kscreenlocker_greet crashes it cannot send SIGUSR2 to kcheckpass and thus kcheckpass becomes an orphan. This can easily be seen in the killTest autotest which results in many orphaned kcheckpass processes after execution. This change uses the linux specific PR_SET_PDEATHSIG to send SIGUSR2 to kcheckpass when the parent process dies. Thus kcheckpass can get out of the waiting and terminate without becoming an orphan. In this case it is not a problem to use a linux specific syscall. The long running kcheckpass is only used if kscreenlocker is built with seccomp support which is also linux specific. Test Plan: Run killTest and check the number of orphaned kcheckpass. Without this change we had 17 orphaned processes, with this change none. Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision:
1 files changed, 5 insertions, 0 deletions
diff --git a/kcheckpass/kcheckpass.c b/kcheckpass/kcheckpass.c
index 02b2ed8..bd18d0b 100644
--- a/kcheckpass/kcheckpass.c
+++ b/kcheckpass/kcheckpass.c
@@ -281,6 +281,11 @@ main(int argc, char **argv)
procctl(P_PID, getpid(), PROC_TRACE_CTL, &mode);
+ // prevent becoming an orphan while waiting for SIGUSR2
/* Make sure stdout/stderr are open */
for (c = 1; c <= 2; c++) {
if (fcntl(c, F_GETFL) == -1) {