Skip to content

Commit

Permalink
squash. Added words about the use of _exit() after a failed call to f…
Browse files Browse the repository at this point in the history
…ork().
  • Loading branch information
korydraughn committed Oct 24, 2024
1 parent 85e24d5 commit c5cbf4a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/main_server/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,13 @@ Mandatory arguments to long options are mandatory for short options too.

if (0 == g_pid_ds) {
execv(args[0], args.data());

// If execv() fails, the POSIX standard recommends using _exit() instead of exit() to avoid
// flushing stdio buffers and handlers registered by the parent.
//
// In the case of C++, this is necessary to avoid triggering destructors. Triggering a destructor
// could result in assertions made by the struct/class being violatied. For some data types,
// violating an assertion results in program termination (i.e. SIGABRT).
_exit(1);
}
else if (g_pid_ds > 0) {
Expand Down

0 comments on commit c5cbf4a

Please sign in to comment.