Fix "host networked game" option
It was broken by b95c9996bf
because
ignoring SIGCHLD makes it impossible to query exit status of wesnothd
subprocess. Fix this by spawning a thread to wait for the browser
instead of ignoring SIGCHLD.
This commit is contained in:
parent
0c745f0fc5
commit
0c3f6da830
2 changed files with 4 additions and 7 deletions
|
@ -19,6 +19,8 @@
|
|||
|
||||
#if defined(_X11) || defined(__APPLE__)
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h> // fork(), exec family
|
||||
|
@ -74,8 +76,8 @@ bool open_object(const std::string& path_or_url)
|
|||
_exit(1); // This shouldn't happen.
|
||||
}
|
||||
|
||||
// Waiting for the child process to exit is unnecessary because we ignore SIGCHLD.
|
||||
// See the manpage for wait(2).
|
||||
std::thread t { [child](){ int status; waitpid(child, &status, 0); } };
|
||||
t.detach();
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -1099,11 +1099,6 @@ 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.
|
||||
|
|
Loading…
Add table
Reference in a new issue