]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - command.c
Pass command exit status via sideband to client.
[paraslash.git] / command.c
index 7b474ab1e9337c85dfc5db7b1a997a0c81e59da0..2cac57f90637f8aa42635700a58b77a688b3ff5d 100644 (file)
--- a/command.c
+++ b/command.c
@@ -1100,7 +1100,8 @@ __noreturn void handle_connect(int fd, const char *peername)
        if (ret >= 0)
                goto out;
 err_out:
-       send_strerror(cc, -ret);
+       if (send_strerror(cc, -ret) >= 0 && cc->use_sideband)
+               send_sb(&cc->scc, NULL, 0, SBD_EXIT__FAILURE, true);
 net_err:
        PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
 out:
@@ -1113,5 +1114,12 @@ out:
                mmd->events++;
        mmd->active_connections--;
        mutex_unlock(mmd_mutex);
+       if (ret < 0)
+               exit(EXIT_FAILURE);
+       if (!cc->use_sideband)
+               exit(EXIT_SUCCESS);
+       ret = send_sb(&cc->scc, NULL, 0, SBD_EXIT__SUCCESS, true);
+       if (ret < 0)
+               PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
        exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
 }