audiod clean_exit(): Only check status fd once
[paraslash.git] / audiod.c
index 52f4ff4cb18919bea60e4106e350fa2d13de6874..8b9f181b80edfb74b31ec08aed23d61d74c8c19f 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -288,8 +288,7 @@ void __noreturn clean_exit(int status, const char *msg)
        PARA_EMERG_LOG("%s\n", msg);
        if (socket_name)
                unlink(socket_name);
-       if (stat_task->fd >= 0)
-               close_stat_pipe();
+       close_stat_pipe();
        exit(status);
 }
 
@@ -882,6 +881,7 @@ static int audiod_get_socket(void)
                exit(EXIT_FAILURE); /* do not unlink socket */
        }
        add_close_on_fork_list(fd);
+       mark_fd_nonblock(fd);
        return fd;
 }
 
@@ -894,6 +894,7 @@ static int open_stat_pipe(void)
                ret = fd[1];
                PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
                add_close_on_fork_list(ret);
+               mark_fd_nonblock(ret);
        } else
                clean_exit(EXIT_FAILURE, "failed to open status pipe");
        return ret;