diff --git a/src/desktop/open.cpp b/src/desktop/open.cpp index 949b9c6e1eb7..4dcd4907ed5d 100644 --- a/src/desktop/open.cpp +++ b/src/desktop/open.cpp @@ -73,11 +73,11 @@ bool open_object(const std::string& path_or_url) } else if(child == 0) { execlp(launcher, launcher, path_or_url.c_str(), nullptr); _exit(1); // This shouldn't happen. - } else if(waitpid(child, &child_status, 0) == -1) { - ERR_DU << "open_object(): waitpid() failed" << std::endl; - return false; } + // Waiting for the child process to exit is unnecessary because we ignore SIGCHLD. + // See the manpage for wait(2). + if(child_status) { //Those status check macros seem to trigger old style casts on some compiler versions #pragma GCC diagnostic push diff --git a/src/wesnoth.cpp b/src/wesnoth.cpp index fa92fa5d7256..74f6021e3737 100644 --- a/src/wesnoth.cpp +++ b/src/wesnoth.cpp @@ -1015,6 +1015,11 @@ int main(int argc, char** argv) sigemptyset(&terminate_handler.sa_mask); sigaction(SIGTERM, &terminate_handler, nullptr); sigaction(SIGINT, &terminate_handler, nullptr); + + // Explicitly ignore SIGCHLD. This allows us to launch child processes without waiting + // for them to exit. See the manpage for wait(2). + terminate_handler.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &terminate_handler, nullptr); #endif //declare this here so that it will always be at the front of the event queue.