Lines 59-64
Link Here
|
59 |
#define PROGNAME "tl-xinit" |
59 |
#define PROGNAME "tl-xinit" |
60 |
#define XAUTH_TIMEOUT 15 |
60 |
#define XAUTH_TIMEOUT 15 |
61 |
#define XSERVER_KILL_TIMEOUT 10 |
61 |
#define XSERVER_KILL_TIMEOUT 10 |
|
|
62 |
#define XCLIENT_KILL_TIMEOUT XSERVER_KILL_TIMEOUT |
62 |
#define SSO_HELPER_TIMEOUT 10 |
63 |
#define SSO_HELPER_TIMEOUT 10 |
63 |
#define TLCONFIG_TIMEOUT 10 |
64 |
#define TLCONFIG_TIMEOUT 10 |
64 |
|
65 |
|
Lines 67-73
Link Here
|
67 |
static volatile short got_signal = 0; |
68 |
static volatile short got_signal = 0; |
68 |
|
69 |
|
69 |
|
70 |
|
70 |
/* Wait for process to exit. Returns 0 if process exited, -1 if still |
71 |
/* Wait for process to exit. Returns 0 if process exited or if pid does not exists, -1 if still |
71 |
around */ |
72 |
around */ |
72 |
static int |
73 |
static int |
73 |
wait_for_exit(pid_t pid, int timeout) |
74 |
wait_for_exit(pid_t pid, int timeout) |
Lines 78-83
Link Here
|
78 |
for (int i = 0; i <= timeout; i++) { |
79 |
for (int i = 0; i <= timeout; i++) { |
79 |
gotpid = waitpid(pid, &status, WNOHANG); |
80 |
gotpid = waitpid(pid, &status, WNOHANG); |
80 |
if (gotpid < 0) { |
81 |
if (gotpid < 0) { |
|
|
82 |
if (errno == ECHILD) { |
83 |
return 0; |
84 |
} |
81 |
perror(PROGNAME ": waitpid"); |
85 |
perror(PROGNAME ": waitpid"); |
82 |
return -1; |
86 |
return -1; |
83 |
} |
87 |
} |
Lines 726-756
Link Here
|
726 |
/* xinit calls XCloseDisplay, but this call will hang, say, if |
730 |
/* xinit calls XCloseDisplay, but this call will hang, say, if |
727 |
Xvnc is STOPped. Avoid that. */ |
731 |
Xvnc is STOPped. Avoid that. */ |
728 |
|
732 |
|
729 |
if (client > 0) { |
733 |
/* Send TERM to client and server processes */ |
730 |
/* Send HUP to process group */ |
734 |
if (kill(client, SIGTERM) < 0) { |
731 |
if (killpg(client, SIGHUP) < 0 && errno != ESRCH) { |
735 |
if (errno != ESRCH) |
732 |
perror(PROGNAME ": Cannot send HUP to client process group"); |
736 |
perror(PROGNAME ": Cannot terminate X client"); |
733 |
} |
|
|
734 |
} |
737 |
} |
735 |
|
738 |
|
736 |
if (xserver > 0) { |
739 |
if (killpg(server, SIGTERM) < 0) { |
737 |
if (killpg(xserver, SIGTERM) < 0) { |
740 |
if (errno != ESRCH) |
738 |
if (errno == ESRCH) { |
741 |
perror(PROGNAME ": Cannot terminate X server"); |
739 |
return; |
742 |
} |
740 |
} |
743 |
|
741 |
perror(PROGNAME ": Cannot terminate X server"); |
744 |
/* Wait for server termination */ |
|
|
745 |
if (wait_for_exit(xserver, XSERVER_KILL_TIMEOUT) < 0) { |
746 |
fprintf(stderr, |
747 |
PROGNAME ": Xserver is slow to shutdown, forcing\n"); |
748 |
|
749 |
if (killpg(xserver, SIGKILL) < 0) { |
750 |
if (errno != ESRCH) { |
751 |
perror(PROGNAME ": X server refuses to terminate"); |
752 |
} |
742 |
} |
753 |
} |
743 |
if (wait_for_exit(xserver, XSERVER_KILL_TIMEOUT) < 0) { |
|
|
744 |
fprintf(stderr, |
745 |
PROGNAME ": Xserver is slow to shutdown, forcing\n"); |
746 |
} |
747 |
if (killpg(xserver, SIGKILL) < 0) { |
748 |
if (errno == ESRCH) { |
749 |
return; |
750 |
} |
751 |
perror(PROGNAME ": X server refuses to terminate"); |
752 |
} |
753 |
} |
754 |
} |
|
|
755 |
|
756 |
/* Wait for client termination */ |
757 |
if (wait_for_exit(client, XCLIENT_KILL_TIMEOUT) < 0) { |
758 |
fprintf(stderr, |
759 |
PROGNAME ": X client is slow to shutdown, forcing\n"); |
760 |
|
761 |
/* best effort to cleanup session processes */ |
762 |
if (killpg(client, SIGKILL) < 0) { |
763 |
if (errno != ESRCH) { |
764 |
perror(PROGNAME ": X client refuses to terminate"); |
765 |
} |
766 |
} |
767 |
} |
754 |
} |
768 |
} |
755 |
|
769 |
|
756 |
|
770 |
|