We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 828abc3 commit 53d3e1bCopy full SHA for 53d3e1b
src/supervisor.c
@@ -109,6 +109,7 @@ static void record_restart(worker_info_t *w) {
109
* @return 0 on success, -1 on error
110
*/
111
static int spawn_worker(int worker_idx) {
112
+ pid_t supervisor_pid = getpid();
113
pid_t pid = fork();
114
115
if (pid < 0) {
@@ -124,7 +125,7 @@ static int spawn_worker(int worker_idx) {
124
125
prctl(PR_SET_PDEATHSIG, SIGTERM);
126
127
/* Check if parent already exited (race condition protection) */
- if (getppid() == 1) {
128
+ if (getppid() != supervisor_pid) {
129
/* Parent already exited, exit immediately */
130
_exit(EXIT_FAILURE);
131
}
0 commit comments