Skip to content

Commit 53d3e1b

Browse files
committed
fix: fix worker keeps crashing in docker
1 parent 828abc3 commit 53d3e1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/supervisor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static void record_restart(worker_info_t *w) {
109109
* @return 0 on success, -1 on error
110110
*/
111111
static int spawn_worker(int worker_idx) {
112+
pid_t supervisor_pid = getpid();
112113
pid_t pid = fork();
113114

114115
if (pid < 0) {
@@ -124,7 +125,7 @@ static int spawn_worker(int worker_idx) {
124125
prctl(PR_SET_PDEATHSIG, SIGTERM);
125126

126127
/* Check if parent already exited (race condition protection) */
127-
if (getppid() == 1) {
128+
if (getppid() != supervisor_pid) {
128129
/* Parent already exited, exit immediately */
129130
_exit(EXIT_FAILURE);
130131
}

0 commit comments

Comments
 (0)