]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Don't close control proxy on hangup
authorRoy Marples <roy@marples.name>
Wed, 17 Mar 2021 14:23:55 +0000 (14:23 +0000)
committerRoy Marples <roy@marples.name>
Wed, 17 Mar 2021 14:23:55 +0000 (14:23 +0000)
Instead wait for it to be closed by the master process for a
clean shtudown.

src/privsep-control.c

index 694242daf99a115a636117e7901035e5e2893560..f216609b10cc5564de763bbae0e6e35fd444921f 100644 (file)
@@ -178,12 +178,12 @@ ps_ctl_recv(void *arg, unsigned short events)
        char buf[BUFSIZ];
        ssize_t len;
 
-       if (events != ELE_READ)
+       if (!(events & ELE_READ))
                logerrx("%s: unexpected event 0x%04x", __func__, events);
 
        errno = 0;
        len = read(ctx->ps_control_data_fd, buf, sizeof(buf));
-       if (len == -1 || len == 0) {
+       if (len == -1) {
                logerr("%s: read", __func__);
                eloop_exit(ctx->eloop, EXIT_FAILURE);
                return;
@@ -203,12 +203,13 @@ ps_ctl_listen(void *arg, unsigned short events)
        ssize_t len;
        struct fd_list *fd;
 
-       if (events != ELE_READ)
+       if (!(events & ELE_READ))
                logerrx("%s: unexpected event 0x%04x", __func__, events);
 
-       errno = 0;
        len = read(ctx->ps_control->fd, buf, sizeof(buf));
-       if (len == -1 || len == 0) {
+       if (len == 0)
+               return;
+       if (len == -1) {
                logerr("%s: read", __func__);
                eloop_exit(ctx->eloop, EXIT_FAILURE);
                return;