diff --git a/drivers/unix/sub_process_unix.cpp b/drivers/unix/sub_process_unix.cpp index ea949e5e1..ef13e946b 100644 --- a/drivers/unix/sub_process_unix.cpp +++ b/drivers/unix/sub_process_unix.cpp @@ -239,98 +239,7 @@ SubProcessUnix::SubProcessUnix() : SubProcess() { _process_fp = NULL; } SubProcessUnix::~SubProcessUnix() { + stop(); } -/* -Error SubProcessUnix::execute(const String &p_path, const List &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) { -#ifdef __EMSCRIPTEN__ - // Don't compile this code at all to avoid undefined references. - // Actual virtual call goes to OS_JavaScript. - ERR_FAIL_V(ERR_BUG); -#else - if (p_blocking && r_pipe) { - String argss; - argss = "\"" + p_path + "\""; - - for (int i = 0; i < p_arguments.size(); i++) { - argss += String(" \"") + p_arguments[i] + "\""; - } - - if (read_stderr) { - argss += " 2>&1"; // Read stderr too - } else { - argss += " 2>/dev/null"; //silence stderr - } - FILE *f = popen(argss.utf8().get_data(), "r"); - - ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot pipe stream from process running with following arguments '" + argss + "'."); - - char buf[65535]; - - while (fgets(buf, 65535, f)) { - if (p_pipe_mutex) { - p_pipe_mutex->lock(); - } - (*r_pipe) += String::utf8(buf); - if (p_pipe_mutex) { - p_pipe_mutex->unlock(); - } - } - int rv = pclose(f); - if (r_exitcode) { - *r_exitcode = WEXITSTATUS(rv); - } - - return OK; - } - - pid_t pid = fork(); - ERR_FAIL_COND_V(pid < 0, ERR_CANT_FORK); - - if (pid == 0) { - // is child - - if (!p_blocking) { - // For non blocking calls, create a new session-ID so parent won't wait for it. - // This ensures the process won't go zombie at end. - setsid(); - } - - Vector cs; - cs.push_back(p_path.utf8()); - for (int i = 0; i < p_arguments.size(); i++) { - cs.push_back(p_arguments[i].utf8()); - } - - Vector args; - for (int i = 0; i < cs.size(); i++) { - args.push_back((char *)cs[i].get_data()); - } - args.push_back(0); - - execvp(p_path.utf8().get_data(), &args[0]); - // still alive? something failed.. - fprintf(stderr, "**ERROR** SubProcessUnix::execute - Could not create child process while executing: %s\n", p_path.utf8().get_data()); - raise(SIGKILL); - } - - if (p_blocking) { - int status; - waitpid(pid, &status, 0); - if (r_exitcode) { - *r_exitcode = WIFEXITED(status) ? WEXITSTATUS(status) : status; - } - - } else { - if (r_child_id) { - *r_child_id = pid; - } - } - - return OK; -#endif -} - -*/ - #endif //posix_enabled