summaryrefslogtreecommitdiffstats
path: root/src/privsep.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-06-10 16:32:04 +0100
committerRoy Marples <roy@marples.name>2020-06-10 16:32:04 +0100
commit536f64cabf24ea7ada1fa0c0fd5e59b5960391f3 (patch)
tree6bef017bb79b775507168251941886c69dd97eac /src/privsep.c
parentc15e4978b45b4d9fc6e3b7bbc28f28b6f06a9ea4 (diff)
downloaddhcpcd-536f64cabf24ea7ada1fa0c0fd5e59b5960391f3.tar.xz
privsep: Fix a shutdown race
Only test a successful stop IPC command. By the time we shutdown the socket to be extra nice, the process we sent stop to could have already exited, therefore we can discard any error.
Diffstat (limited to 'src/privsep.c')
-rw-r--r--src/privsep.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/privsep.c b/src/privsep.c
index b2f3b309..d05681aa 100644
--- a/src/privsep.c
+++ b/src/privsep.c
@@ -401,17 +401,16 @@ ps_dostop(struct dhcpcd_ctx *ctx, pid_t *pid, int *fd)
int err = 0;
#ifdef PRIVSEP_DEBUG
- logdebugx("%s: pid %d fd %d", __func__, *pid, *fd);
+ logdebugx("%s: pid=%d fd=%d", __func__, *pid, *fd);
#endif
if (*fd != -1) {
eloop_event_delete(ctx->eloop, *fd);
- if (ps_sendcmd(ctx, *fd, PS_STOP, 0, NULL, 0) == -1 ||
- shutdown(*fd, SHUT_RDWR) == -1)
- {
+ if (ps_sendcmd(ctx, *fd, PS_STOP, 0, NULL, 0) == -1) {
logerr(__func__);
err = -1;
}
+ (void)shutdown(*fd, SHUT_RDWR);
close(*fd);
*fd = -1;
}