From 66d85d702bca5cda564fa2a79a81ffd895ff2712 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 27 Feb 2026 10:17:40 -0500 Subject: [PATCH] Terminal & Expander: Replace exit() with _exit() in fork+exec failure path. This is necessary to avoid destructors being called in the child, potentially messing up parent state. --- src/apps/expander/ExpanderThread.cpp | 4 ++-- src/apps/terminal/Shell.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/apps/expander/ExpanderThread.cpp b/src/apps/expander/ExpanderThread.cpp index 6ee078cb63..a37f0c900e 100644 --- a/src/apps/expander/ExpanderThread.cpp +++ b/src/apps/expander/ExpanderThread.cpp @@ -258,8 +258,8 @@ ExpanderThread::PipeCommand(int argc, const char** argv, int& in, int& out, // "load" command. execv(argv[0], (char *const *)argv); - // shouldn't return - return -1; + // shouldn't get here + _exit(-1); } // parent diff --git a/src/apps/terminal/Shell.cpp b/src/apps/terminal/Shell.cpp index 4cf7cbbeba..6a6bc5851f 100644 --- a/src/apps/terminal/Shell.cpp +++ b/src/apps/terminal/Shell.cpp @@ -432,7 +432,7 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) snprintf(handshake.msg, sizeof(handshake.msg), "could not set session leader."); send_handshake_message(terminalThread, handshake); - exit(1); + _exit(1); } /* open slave pty */ @@ -442,7 +442,7 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) snprintf(handshake.msg, sizeof(handshake.msg), "can't open tty (%s).", ttyName); send_handshake_message(terminalThread, handshake); - exit(1); + _exit(1); } /* set signal default */ @@ -487,7 +487,7 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) snprintf(handshake.msg, sizeof(handshake.msg), "failed set terminal interface (TERMIOS)."); send_handshake_message(terminalThread, handshake); - exit(1); + _exit(1); } /* @@ -503,7 +503,7 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) snprintf(handshake.msg, sizeof(handshake.msg), "mismatch handshake."); send_handshake_message(terminalThread, handshake); - exit(1); + _exit(1); } struct winsize ws = { handshake.row, handshake.col }; @@ -553,7 +553,7 @@ Shell::_Spawn(int row, int col, const ShellParameters& parameters) "-l", NULL); } - exit(1); + _exit(1); } /*