Skip to content

Commit 2e0da50

Browse files
Merge pull request #161 from indexdata/fix-daemon-keepalive-waitpid-eintr
daemon keepalive: fix waitpid EINTR handling
2 parents 3d7139b + 6fb02c7 commit 2e0da50

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/daemon.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,19 @@ static void keepalive(void (*work)(void *data), void *data)
137137
/* enable signalling in kill_child_handler */
138138
child_pid = p;
139139

140-
p1 = waitpid(p, &status, 0);
140+
// wait for child to finish and check status
141+
while ((p1 = waitpid(p, &status, 0) == (pid_t ) (-1)) && errno == EINTR)
142+
;
143+
144+
if (p1 == (pid_t) (-1))
145+
{
146+
yaz_log(YLOG_FATAL|YLOG_ERRNO, "waitpid");
147+
break;
148+
}
141149

142150
/* disable signalling in kill_child_handler */
143151
child_pid = 0;
144152

145-
if (p1 == (pid_t)(-1))
146-
{
147-
if (errno != EINTR)
148-
{
149-
yaz_log(YLOG_FATAL|YLOG_ERRNO, "waitpid");
150-
break;
151-
}
152-
continue;
153-
}
154153
if (p1 != p)
155154
{
156155
yaz_log(YLOG_FATAL, "p1=%d != p=%d", p1, p);

0 commit comments

Comments
 (0)