summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-08-03 13:18:05 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-08-03 13:21:30 +0200
commit8d688c93a1b2d8a7b4069cebc46efa129ae4c1cc (patch)
tree79ab27db51e051fad7ea1e304d0387a3c0bc61f8
parent2023bae19975914dc8c5b79567e0248b507d5991 (diff)
daemon: also wait for the end of the session process
-rw-r--r--src/daemon/entrance_session.c12
-rw-r--r--src/daemon/entrance_wait.c25
2 files changed, 28 insertions, 9 deletions
diff --git a/src/daemon/entrance_session.c b/src/daemon/entrance_session.c
index 3a9727f..159d9ef 100644
--- a/src/daemon/entrance_session.c
+++ b/src/daemon/entrance_session.c
@@ -188,6 +188,14 @@ _entrance_session_run(struct passwd *pwd, const char *cmd, const char *cookie)
188 execle(pwd->pw_shell, pwd->pw_shell, "--login", "-c", buf, NULL, env); 188 execle(pwd->pw_shell, pwd->pw_shell, "--login", "-c", buf, NULL, env);
189 PT("The Xsessions are not launched :("); 189 PT("The Xsessions are not launched :(");
190 } 190 }
191 else if (pid > 0)
192 {
193 entrance_session_pid_set(pid);
194 }
195 else
196 {
197 ERR("Failed to start session");
198 }
191} 199}
192 200
193void 201void
@@ -217,8 +225,12 @@ entrance_session_close(const Eina_Bool opened)
217void 225void
218entrance_session_pid_set(pid_t pid) 226entrance_session_pid_set(pid_t pid)
219{ 227{
228 char buf[PATH_MAX];
229
220 PT("%s: session pid %d", PACKAGE, pid); 230 PT("%s: session pid %d", PACKAGE, pid);
221 _session_pid = pid; 231 _session_pid = pid;
232 snprintf(buf, sizeof(buf), "%d", pid);
233 setenv("ENTRANCE_SPID", buf, 1);
222} 234}
223 235
224pid_t 236pid_t
diff --git a/src/daemon/entrance_wait.c b/src/daemon/entrance_wait.c
index 2a3f0f5..b34e913 100644
--- a/src/daemon/entrance_wait.c
+++ b/src/daemon/entrance_wait.c
@@ -33,11 +33,15 @@ main (int argc __UNUSED__, char **argv __UNUSED__)
33{ 33{
34 int status = 0; 34 int status = 0;
35 char *pid; 35 char *pid;
36 char *sid;
36 struct sigaction action; 37 struct sigaction action;
37 38
38 pid_t rpid; 39 pid_t rpid, spid;
39 pid = getenv("ENTRANCE_XPID"); 40 pid = getenv("ENTRANCE_XPID");
41 sid = getenv("ENTRANCE_SPID");
40 if (!pid) return -1; 42 if (!pid) return -1;
43 if (!sid) return -1;
44 spid = atoi(sid);
41 _x_pid = atoi(pid); 45 _x_pid = atoi(pid);
42 printf("waiting\n"); 46 printf("waiting\n");
43 47
@@ -53,20 +57,23 @@ main (int argc __UNUSED__, char **argv __UNUSED__)
53 sigaction(SIGPIPE, &action, NULL); 57 sigaction(SIGPIPE, &action, NULL);
54 sigaction(SIGALRM, &action, NULL); 58 sigaction(SIGALRM, &action, NULL);
55 59
56 while ((rpid = wait(&status)) != _x_pid) 60 while ((rpid = wait(&status)))
57 { 61 {
58 if (rpid == -1) 62 if (rpid == -1)
59 { 63 {
60 if ((errno == ECHILD) || (errno == EINVAL)) 64 if ((errno == ECHILD) || (errno == EINVAL))
61 break; 65 return -1;
66 }
67 else if (rpid == _x_pid || rpid == spid)
68 {
69 break;
62 } 70 }
63 } 71 }
64 if (_x_pid == rpid) 72
65 { 73 if (WIFEXITED(status) && WEXITSTATUS(status))
66 if (WIFEXITED(status) && WEXITSTATUS(status)) 74 setenv("ENTRANCE_QUIT", "1", 1);
67 setenv("ENTRANCE_QUIT", "1", 1); 75 execlp(PACKAGE_SBIN_DIR"/entrance", PACKAGE_SBIN_DIR"/entrance", "--nodaemon", NULL);
68 execlp(PACKAGE_SBIN_DIR"/entrance", PACKAGE_SBIN_DIR"/entrance", "--nodaemon", NULL); 76
69 }
70 return -1; 77 return -1;
71} 78}
72 79