JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Call _exit() instead of exit() if exec*() fails
authorsin <sin@2f30.org>
Tue, 11 Nov 2014 18:29:11 +0000 (18:29 +0000)
committerRoberto E. Vargas Caballero <k0ga@shike2.com>
Wed, 19 Nov 2014 17:52:42 +0000 (18:52 +0100)
exit() will also unwind the atexit() functions.  This is bad
because if exec*() fails the process is in an inconsistent state.

st.c

diff --git a/st.c b/st.c
index 068fbb3..4499be6 100644 (file)
--- a/st.c
+++ b/st.c
@@ -1190,7 +1190,7 @@ execsh(void) {
        signal(SIGALRM, SIG_DFL);
 
        execvp(prog, args);
        signal(SIGALRM, SIG_DFL);
 
        execvp(prog, args);
-       exit(EXIT_FAILURE);
+       _exit(EXIT_FAILURE);
 }
 
 void
 }
 
 void