wait for xserver end

devs/bu5hm4n/session_bug
Michael Bouchaud 8 years ago
parent 46c7cc4214
commit 60ee7d4596
  1. 4
      src/daemon/entrance.c
  2. 25
      src/daemon/entrance_xserver.c

@ -352,6 +352,7 @@ main (int argc, char ** argv)
if (entrance_user)
{
char *quit;
entrance_xserver_wait();
entrance_session_init(dname);
entrance_session_end(entrance_user);
entrance_session_shutdown();
@ -361,8 +362,6 @@ main (int argc, char ** argv)
unsetenv("ENTRANCE_QUIT");
PT("Last DE Session quit with error!\n");
}
PT("ending xserver\n");
entrance_xserver_end();
_remove_lock();
PT("Entrance will quit, bye bye :).\n");
entrance_close_log();
@ -466,6 +465,7 @@ main (int argc, char ** argv)
PT("ending xserver\n");
kill(pid, SIGTERM);
entrance_xserver_end();
entrance_xserver_wait();
}
else
PT("No session to wait, exiting\n");

@ -123,17 +123,36 @@ entrance_xserver_init(Entrance_X_Cb start, const char *dname)
return pid;
}
void
entrance_xserver_wait(void)
{
const char *xpid;
int pid;
PT("xserver end");
xpid = getenv("ENTRANCE_XPID");
if (xpid)
{
pid = atoi(xpid);
while (waitpid(pid, NULL, WUNTRACED | WCONTINUED) > 0)
{
printf(".");
sleep(1);
}
unsetenv("ENTRANCE_XPID");
}
printf("\n");
}
void
entrance_xserver_end(void)
{
const char *xpid;
PT("xserver end\n");
xpid = getenv("ENTRANCE_XPID");
if (xpid)
if (xpid)
kill(atoi(xpid), SIGTERM);
unsetenv("ENTRANCE_XPID");
while (waitpid(-1, NULL, WNOHANG) > 0);
}
void

Loading…
Cancel
Save