From 090b31c8012dab19d7666a96cb2d3c8b272bc885 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 31 Jul 2007 16:24:31 +0000 Subject: SWIG building fixes. Applied patch from silverblade to fix Raul Process cmd line parameters. Fixed launching internal engine from Connect dialog. Fix nasty crashes caused by overly hasty last commit. git-svn-id: http://svn.drobilla.net/lad/raul@662 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Process.hpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'raul') diff --git a/raul/Process.hpp b/raul/Process.hpp index 80063a1..2f5e286 100644 --- a/raul/Process.hpp +++ b/raul/Process.hpp @@ -46,27 +46,29 @@ public: ? command.substr(0, command.find(" ")) : command; - std::cerr << "Launching child process '" << executable << "' with command line '" - << command << "'" << std::endl; + const std::string arguments = command.substr((command.find(" ") + 1)); - // Use the same double fork() trick as JACK to prevent zombie children - const int err = fork(); + std::cerr << "Launching child process '" << executable << "' with arguments '" + << arguments << "'" << std::endl; - if (err == 0) { - // (child) + // Use the same double fork() trick as JACK to prevent zombie children + const int err = fork(); - // close all nonstandard file descriptors - struct rlimit max_fds; - getrlimit(RLIMIT_NOFILE, &max_fds); + if (err == 0) { + // (child) - for (rlim_t fd = 3; fd < max_fds.rlim_cur; ++fd) - close(fd); + // close all nonstandard file descriptors + struct rlimit max_fds; + getrlimit(RLIMIT_NOFILE, &max_fds); - switch (fork()) { - case 0: - // (grandchild) - setsid(); - execlp(executable.c_str(), command.c_str(), NULL); + for (rlim_t fd = 3; fd < max_fds.rlim_cur; ++fd) + close(fd); + + switch (fork()) { + case 0: + // (grandchild) + setsid(); + execlp(executable.c_str(), arguments.c_str(), NULL); _exit(-1); case -1: -- cgit v1.2.1