On OSX, we use boost::process::spawn() to launch new instances of PrusaSlicer from another PrusaSlicer.

boost::process::spawn() sets SIGCHLD to SIGIGN for the child process, thus if a child PrusaSlicer spawns another
subprocess and the subrocess dies, the child PrusaSlicer will not receive information on end of subprocess
(posix waitpid() call will always fail).
https://jmmv.dev/2008/10/boostprocess-and-sigchld.html
The child instance of PrusaSlicer has to reset SIGCHLD to its default, so that posix waitpid() and similar continue to work.
Fixes #5507
This commit is contained in:
Vojtech Bubnik 2021-01-07 19:14:48 +01:00
parent 71808dc006
commit 2b02747ec5
2 changed files with 21 additions and 6 deletions

View file

@ -16,11 +16,26 @@
#include <boost/nowide/iostream.hpp>
#include <boost/nowide/convert.hpp>
#if __APPLE__
#include <signal.h>
#endif // __APPLE__
namespace Slic3r {
namespace GUI {
int GUI_Run(GUI_InitParams &params)
{
#if __APPLE__
// On OSX, we use boost::process::spawn() to launch new instances of PrusaSlicer from another PrusaSlicer.
// boost::process::spawn() sets SIGCHLD to SIGIGN for the child process, thus if a child PrusaSlicer spawns another
// subprocess and the subrocess dies, the child PrusaSlicer will not receive information on end of subprocess
// (posix waitpid() call will always fail).
// https://jmmv.dev/2008/10/boostprocess-and-sigchld.html
// The child instance of PrusaSlicer has to reset SIGCHLD to its default, so that posix waitpid() and similar continue to work.
// See GH issue #5507
signal(SIGCHLD, SIG_DFL);
#endif // __APPLE__
try {
GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor);
if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) {