_exit() instead of exit() after failed exec
authorFRIGN <dev@frign.de>
Thu, 11 Aug 2016 19:20:07 +0000 (21:20 +0200)
committerMarkus Teich <markus.teich@stusta.mhn.de>
Thu, 11 Aug 2016 21:42:09 +0000 (23:42 +0200)
die() calls exit(), but actually at this point the program could be in a
state not allowing this. It's better to call _exit to stop the libc from
calling any handlers that might fail at this moment anyway.

sent.c

diff --git a/sent.c b/sent.c
index f6c57fb371adf91df0d795b342227941daf3c3dc..a4d0cd25ac11d8c2c0f35b4a2d19f1722116e927 100644 (file)
--- a/sent.c
+++ b/sent.c
@@ -150,7 +150,8 @@ filter(int fd, const char *cmd)
                close(fds[0]);
                close(fds[1]);
                execlp("sh", "sh", "-c", cmd, (char *)0);
-               die("sent: execlp sh -c '%s':", cmd);
+               fprintf(stderr, "sent: execlp sh -c '%s': %s\n", cmd, strerror(errno));
+               _exit(1);
        }
        close(fds[1]);
        return fds[0];