author | Gregory Szorc <gregory.szorc@gmail.com> |
Fri, 12 Oct 2018 16:19:21 +0200 | |
changeset 40180 | ba70e3acf58a |
parent 40119 | e70b616a077b |
child 41336 | 763b45bc4483 |
permissions | -rw-r--r-- |
28060 | 1 |
/* |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
2 |
* Signal handlers for cHg |
28060 | 3 |
* |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
4 |
* Copyright 2011, 2018 Yuya Nishihara <yuya@tcha.org> |
28060 | 5 |
* |
6 |
* This software may be used and distributed according to the terms of the |
|
7 |
* GNU General Public License version 2 or any later version. |
|
8 |
*/ |
|
9 |
||
30693 | 10 |
#include <assert.h> |
11 |
#include <errno.h> |
|
12 |
#include <signal.h> |
|
13 |
#include <string.h> |
|
14 |
#include <unistd.h> |
|
15 |
||
29608
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
16 |
static pid_t peerpgid = 0; |
28060 | 17 |
static pid_t peerpid = 0; |
18 |
||
19 |
static void forwardsignal(int sig) |
|
20 |
{ |
|
21 |
assert(peerpid > 0); |
|
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
22 |
(void)kill(peerpid, sig); |
28060 | 23 |
} |
24 |
||
29608
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
25 |
static void forwardsignaltogroup(int sig) |
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
26 |
{ |
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
27 |
/* prefer kill(-pgid, sig), fallback to pid if pgid is invalid */ |
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
28 |
pid_t killpid = peerpgid > 1 ? -peerpgid : peerpid; |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
29 |
(void)kill(killpid, sig); |
29608
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
30 |
} |
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
31 |
|
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
32 |
static void handlestopsignal(int sig) |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
33 |
{ |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
34 |
sigset_t unblockset, oldset; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
35 |
struct sigaction sa, oldsa; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
36 |
if (sigemptyset(&unblockset) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
37 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
38 |
if (sigaddset(&unblockset, sig) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
39 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
40 |
memset(&sa, 0, sizeof(sa)); |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
41 |
sa.sa_handler = SIG_DFL; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
42 |
sa.sa_flags = SA_RESTART; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
43 |
if (sigemptyset(&sa.sa_mask) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
44 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
45 |
|
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
46 |
forwardsignal(sig); |
35959
9724f54923ec
chg: enable clang-format on all .c and .h files
Augie Fackler <augie@google.com>
parents:
31941
diff
changeset
|
47 |
if (raise(sig) < 0) /* resend to self */ |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
48 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
49 |
if (sigaction(sig, &sa, &oldsa) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
50 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
51 |
if (sigprocmask(SIG_UNBLOCK, &unblockset, &oldset) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
52 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
53 |
/* resent signal will be handled before sigprocmask() returns */ |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
54 |
if (sigprocmask(SIG_SETMASK, &oldset, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
55 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
56 |
if (sigaction(sig, &oldsa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
57 |
return; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
58 |
} |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
59 |
|
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
60 |
/* |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
61 |
* Installs signal handlers. |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
62 |
* |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
63 |
* Returns 0 on success, -1 on error and errno is set appropriately. |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
64 |
* Installed handlers wouldn't be cleaned up on error. |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
65 |
*/ |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
66 |
int setupsignalhandler(pid_t pid, pid_t pgid) |
28060 | 67 |
{ |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
68 |
if (pid <= 0) { |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
69 |
errno = EINVAL; |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
70 |
return -1; |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
71 |
} |
28060 | 72 |
peerpid = pid; |
29608
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
73 |
peerpgid = (pgid <= 1 ? 0 : pgid); |
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
74 |
|
28060 | 75 |
struct sigaction sa; |
76 |
memset(&sa, 0, sizeof(sa)); |
|
31229
68c94f286e25
chg: document why we send SIGHUP and SIGINT to process group
Jun Wu <quark@fb.com>
parents:
30693
diff
changeset
|
77 |
|
68c94f286e25
chg: document why we send SIGHUP and SIGINT to process group
Jun Wu <quark@fb.com>
parents:
30693
diff
changeset
|
78 |
/* deadly signals meant to be sent to a process group: |
68c94f286e25
chg: document why we send SIGHUP and SIGINT to process group
Jun Wu <quark@fb.com>
parents:
30693
diff
changeset
|
79 |
* - SIGHUP: usually generated by the kernel, when termination of a |
68c94f286e25
chg: document why we send SIGHUP and SIGINT to process group
Jun Wu <quark@fb.com>
parents:
30693
diff
changeset
|
80 |
* process causes that process group to become orphaned |
68c94f286e25
chg: document why we send SIGHUP and SIGINT to process group
Jun Wu <quark@fb.com>
parents:
30693
diff
changeset
|
81 |
* - SIGINT: usually generated by the terminal */ |
29608
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
82 |
sa.sa_handler = forwardsignaltogroup; |
28060 | 83 |
sa.sa_flags = SA_RESTART; |
28085
c0d1bf1b26b7
chg: verify return value of sigaction() and sigemptyset()
Yuya Nishihara <yuya@tcha.org>
parents:
28084
diff
changeset
|
84 |
if (sigemptyset(&sa.sa_mask) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
85 |
return -1; |
28085
c0d1bf1b26b7
chg: verify return value of sigaction() and sigemptyset()
Yuya Nishihara <yuya@tcha.org>
parents:
28084
diff
changeset
|
86 |
if (sigaction(SIGHUP, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
87 |
return -1; |
28085
c0d1bf1b26b7
chg: verify return value of sigaction() and sigemptyset()
Yuya Nishihara <yuya@tcha.org>
parents:
28084
diff
changeset
|
88 |
if (sigaction(SIGINT, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
89 |
return -1; |
28060 | 90 |
|
91 |
/* terminate frontend by double SIGTERM in case of server freeze */ |
|
29608
681fe090d82e
chg: forward SIGINT, SIGHUP to process group
Jun Wu <quark@fb.com>
parents:
29440
diff
changeset
|
92 |
sa.sa_handler = forwardsignal; |
28060 | 93 |
sa.sa_flags |= SA_RESETHAND; |
28085
c0d1bf1b26b7
chg: verify return value of sigaction() and sigemptyset()
Yuya Nishihara <yuya@tcha.org>
parents:
28084
diff
changeset
|
94 |
if (sigaction(SIGTERM, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
95 |
return -1; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
96 |
|
28980 | 97 |
/* notify the worker about window resize events */ |
98 |
sa.sa_flags = SA_RESTART; |
|
99 |
if (sigaction(SIGWINCH, &sa, NULL) < 0) |
|
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
100 |
return -1; |
31230 | 101 |
/* forward user-defined signals */ |
102 |
if (sigaction(SIGUSR1, &sa, NULL) < 0) |
|
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
103 |
return -1; |
31230 | 104 |
if (sigaction(SIGUSR2, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
105 |
return -1; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
106 |
/* propagate job control requests to worker */ |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
107 |
sa.sa_handler = forwardsignal; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
108 |
sa.sa_flags = SA_RESTART; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
109 |
if (sigaction(SIGCONT, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
110 |
return -1; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
111 |
sa.sa_handler = handlestopsignal; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
112 |
sa.sa_flags = SA_RESTART; |
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
113 |
if (sigaction(SIGTSTP, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
114 |
return -1; |
28086
65d24ca35496
chg: forward job control signals to worker process (issue5051)
Yuya Nishihara <yuya@tcha.org>
parents:
28085
diff
changeset
|
115 |
|
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
116 |
return 0; |
28060 | 117 |
} |
118 |
||
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
119 |
/* |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
120 |
* Restores signal handlers to the default, and masks SIGINT. |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
121 |
* |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
122 |
* Returns 0 on success, -1 on error and errno is set appropriately. |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
123 |
*/ |
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
124 |
int restoresignalhandler(void) |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
125 |
{ |
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
126 |
struct sigaction sa; |
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
127 |
memset(&sa, 0, sizeof(sa)); |
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
128 |
sa.sa_handler = SIG_DFL; |
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
129 |
sa.sa_flags = SA_RESTART; |
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
130 |
if (sigemptyset(&sa.sa_mask) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
131 |
return -1; |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
132 |
|
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
133 |
if (sigaction(SIGHUP, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
134 |
return -1; |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
135 |
if (sigaction(SIGTERM, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
136 |
return -1; |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
137 |
if (sigaction(SIGWINCH, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
138 |
return -1; |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
139 |
if (sigaction(SIGCONT, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
140 |
return -1; |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
141 |
if (sigaction(SIGTSTP, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
142 |
return -1; |
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
143 |
|
29370
3ddf4d0c4170
chg: ignore SIGINT while waiting pager termination
Yuya Nishihara <yuya@tcha.org>
parents:
29369
diff
changeset
|
144 |
/* ignore Ctrl+C while shutting down to make pager exits cleanly */ |
3ddf4d0c4170
chg: ignore SIGINT while waiting pager termination
Yuya Nishihara <yuya@tcha.org>
parents:
29369
diff
changeset
|
145 |
sa.sa_handler = SIG_IGN; |
3ddf4d0c4170
chg: ignore SIGINT while waiting pager termination
Yuya Nishihara <yuya@tcha.org>
parents:
29369
diff
changeset
|
146 |
if (sigaction(SIGINT, &sa, NULL) < 0) |
40118
cd490ac908c0
rust-chg: extract signal handlers from chg/procutil.c
Yuya Nishihara <yuya@tcha.org>
parents:
35959
diff
changeset
|
147 |
return -1; |
29370
3ddf4d0c4170
chg: ignore SIGINT while waiting pager termination
Yuya Nishihara <yuya@tcha.org>
parents:
29369
diff
changeset
|
148 |
|
29369
85a18f3c0bdd
chg: reset signal handlers to default before waiting pager
Yuya Nishihara <yuya@tcha.org>
parents:
29357
diff
changeset
|
149 |
peerpid = 0; |
29344 | 150 |
return 0; |
151 |
} |