shutdown: set passed-via-environment control socket to blocking.
authorDavin McCall <davmac@davmac.org>
Wed, 16 May 2018 12:24:07 +0000 (13:24 +0100)
committerDavin McCall <davmac@davmac.org>
Mon, 21 May 2018 17:29:45 +0000 (18:29 +0100)
We don't expect non-blocking errors like EAGAIN so we need it in
blocking mode.

src/shutdown.cc

index 511553f50f08eb3ad5589db928d60274d29de405..c9bb8b50425020df03766566f43bba58d0ccb1b7 100644 (file)
@@ -307,6 +307,9 @@ int main(int argc, char **argv)
             long int cfdnum = strtol(dinit_cs_fd_env, &endptr, 10);
             if (endptr != dinit_cs_fd_env) {
                 socknum = (int) cfdnum;
+                // Set non-blocking mode:
+                int sock_flags = fcntl(socknum, F_GETFL, 0);
+                fcntl(socknum, F_SETFL, sock_flags & ~O_NONBLOCK);
             }
             else {
                 use_passed_cfd = false;