File 0001-boost-process-posix.patch of Package OrcaSlicer

diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp
--- a/src/slic3r/GUI/MediaPlayCtrl.cpp
+++ b/src/slic3r/GUI/MediaPlayCtrl.cpp
@@ -13,12 +13,16 @@
 #include <boost/nowide/cstdio.hpp>
 #include <boost/nowide/utf8_codecvt.hpp>
 #undef pid_t
+#ifdef __WXMSW__
 #include <boost/process.hpp>
-#ifdef __WIN32__
 #include <boost/process/windows.hpp>
-#else
+#endif
+
+#ifndef _WIN32
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#include <unistd.h>
+#include <sys/wait.h>
 #endif
 
 #include <wx/clipbrd.h>
@@ -746,6 +750,7 @@
     try {
         std::string configs;
         load_string_file(file_ff_cfg, configs);
         std::vector<std::string> configss;
         boost::algorithm::split(configss, configs, boost::algorithm::is_any_of("\r\n"));
         configss.erase(std::remove(configss.begin(), configss.end(), std::string()), configss.end());
+#ifdef __WXMSW__
         boost::process::pipe intermediate;
         boost::filesystem::path start_dir(boost::filesystem::path(data_dir()) / "plugins");
 #ifdef __WXMSW__
@@ -762,16 +767,27 @@
         boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::windows::create_no_window, 
                                              boost::process::std_in < intermediate, boost::process::limit_handles);
 #else
-        boost::filesystem::permissions(file_source, boost::filesystem::owner_exe | boost::filesystem::add_perms);
-        boost::filesystem::permissions(file_ffmpeg, boost::filesystem::owner_exe | boost::filesystem::add_perms);
-        boost::process::child process_source(file_source, file_url2.data().AsInternal(), boost::process::start_dir(start_dir), 
-                                             boost::process::std_out > intermediate, boost::process::limit_handles);
-        boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::std_in < intermediate, boost::process::limit_handles);
-#endif
         process_source.detach();
         process_ffmpeg.detach();
+#endif
+#else
+        // Linux: use POSIX fork/exec/pipe instead of boost::process (removed in Boost 1.90)
+        boost::filesystem::path start_dir(boost::filesystem::path(data_dir()) / "plugins");
+        boost::filesystem::permissions(file_source, boost::filesystem::owner_exe | boost::filesystem::add_perms);
+        boost::filesystem::permissions(file_ffmpeg, boost::filesystem::owner_exe | boost::filesystem::add_perms);
+        int pipefd[2];
+        if (::pipe(pipefd) == -1) {
+            BOOST_LOG_TRIVIAL(error) << "MediaPlayCtrl: pipe() failed";
+            return false;
+        }
+        pid_t pid1 = fork();
+        if (pid1 == 0) { ::close(pipefd[0]); dup2(pipefd[1], STDOUT_FILENO); ::close(pipefd[1]); chdir(start_dir.string().c_str()); execl(file_source.c_str(), file_source.c_str(), file_url2.utf8_str().data(), nullptr); _exit(1); }
+        std::string cmd = file_ffmpeg; for (auto& c : configss) cmd += " " + c;
+        pid_t pid2 = fork();
+        if (pid2 == 0) { ::close(pipefd[1]); dup2(pipefd[0], STDIN_FILENO); ::close(pipefd[0]); execl("/bin/sh", "sh", "-c", cmd.c_str(), nullptr); _exit(1); }
+        ::close(pipefd[0]); ::close(pipefd[1]);
+#endif
     } catch (std::exception &e) {
         BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl failed to start camera stream: " << decode_path(e.what());
         return false;
diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp
--- a/src/slic3r/GUI/RemovableDriveManager.cpp
+++ b/src/slic3r/GUI/RemovableDriveManager.cpp
@@ -22,7 +22,8 @@
 #include <pwd.h>
 #include <boost/filesystem.hpp>
 #include <boost/system/error_code.hpp>
-#include <boost/process.hpp>
+#include <unistd.h>
+#include <sys/wait.h>
 #endif
 
 namespace Slic3r {
@@ -300,35 +301,26 @@
 	{
 		//std::cout<<"Ejecting "<<(*it).name<<" from "<< correct_path<<"\n";
 		// there is no usable command in c++ so terminal command is used instead
 		// but neither triggers "succesful safe removal messege"
-		
 		BOOST_LOG_TRIVIAL(info) << "Ejecting started";
-		boost::process::ipstream istd_err;
-    	boost::process::child child(
-#if __APPLE__		
-			boost::process::search_path("diskutil"), "eject", correct_path.c_str(), (boost::process::std_out & boost::process::std_err) > istd_err);
-		//Another option how to eject at mac. Currently not working.
-		//used insted of system() command;
-		//this->eject_device(correct_path);
+#if __APPLE__
+		std::string eject_cmd = std::string("diskutil eject '") + correct_path + "' 2>&1";
 #else
-    		boost::process::search_path("umount"), correct_path.c_str(), (boost::process::std_out & boost::process::std_err) > istd_err);
+		std::string eject_cmd = std::string("umount '") + correct_path + "' 2>&1";
 #endif
-		std::string line;
-		while (child.running() && std::getline(istd_err, line)) {
-			BOOST_LOG_TRIVIAL(trace) << line;
-		}
-		// wait for command to finnish (blocks ui thread)
-		std::error_code ec;
-		child.wait(ec);
 		bool success = false;
-		if (ec) {
-            // The wait call can fail
-            // It can happen even in cases where the eject is sucessful, but better report it as failed.
-            // We did not find a way to reliably retrieve the exit code of the process.
-			BOOST_LOG_TRIVIAL(error) << "boost::process::child::wait() failed during Ejection. State of Ejection is unknown. Error code: " << ec.value();
+		FILE* fp = popen(eject_cmd.c_str(), "r");
+		if (!fp) {
+			BOOST_LOG_TRIVIAL(error) << "Ejecting failed: popen() failed";
 		} else {
-			int err = child.exit_code();
-	    	if (err) {
-	    		BOOST_LOG_TRIVIAL(error) << "Ejecting failed. Exit code: " << err;
-	    	} else {
+			char buf[256];
+			while (fgets(buf, sizeof(buf), fp)) {
+				BOOST_LOG_TRIVIAL(trace) << buf;
+			}
+			int ret = pclose(fp);
+			int err = WIFEXITED(ret) ? WEXITSTATUS(ret) : -1;
+			if (err) {
+				BOOST_LOG_TRIVIAL(error) << "Ejecting failed. Exit code: " << err;
+			} else {
 				BOOST_LOG_TRIVIAL(info) << "Ejecting finished";
 				success = true;
 			}

openSUSE Build Service is sponsored by