diff libinterp/corefcn/toplev.cc @ 22264:9b78fda78300

fix build failure for --without-z (bug #48757) * liboctave/wrappers/async-system-wrapper.h, liboctave/wrappers/async-system-wrapper.c: New files for function extracted from Fsystem. * liboctave/wrappers/module.mk: Update. * toplev.cc: Include async-system-wrapper.h. (Fsystem): Use new octave_async_system_wrapper for async case. * oct-procbuf.cc: Include unistd.h, reluctantly. Use HAVE_UNISTD_H instead of HAVE_SYS_WAIT_H for conditional code.
author John W. Eaton <jwe@octave.org>
date Thu, 11 Aug 2016 12:33:26 -0400
parents 9203833cab7d
children bac0d6f07a3e
line wrap: on
line diff
--- a/libinterp/corefcn/toplev.cc	Thu Aug 11 08:16:52 2016 -0400
+++ b/libinterp/corefcn/toplev.cc	Thu Aug 11 12:33:26 2016 -0400
@@ -36,6 +36,7 @@
 #  include <windows.h>
 #endif
 
+#include "async-system-wrapper.h"
 #include "child-list.h"
 #include "lo-error.h"
 #include "oct-fftw.h"
@@ -246,41 +247,7 @@
 #endif
 
   if (type == et_async)
-    {
-      // FIXME: maybe this should go in sysdep.cc?
-#if defined (HAVE_FORK)
-      pid_t pid = fork ();
-
-      if (pid < 0)
-        error ("system: fork failed -- can't create child process");
-      else if (pid == 0)
-        {
-          // FIXME: should probably replace this call with something portable.
-          execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
-                 static_cast<char *> (0));
-
-          panic_impossible ();
-        }
-      else
-        retval(0) = pid;
-#elif defined (OCTAVE_USE_WINDOWS_API)
-      STARTUPINFO si;
-      PROCESS_INFORMATION pi;
-      ZeroMemory (&si, sizeof (si));
-      ZeroMemory (&pi, sizeof (pi));
-      OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
-      strcpy (xcmd_str, cmd_str.c_str ());
-
-      if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
-        error ("system: CreateProcess failed -- can't create child process");
-
-      retval(0) = pi.dwProcessId;
-      CloseHandle (pi.hProcess);
-      CloseHandle (pi.hThread);
-#else
-      err_disabled_feature ("system", "asynchronous system calls");
-#endif
-    }
+    retval(0) = octave_async_system_wrapper (cmd_str.c_str ());
   else if (return_output)
     retval = run_command_and_return_output (cmd_str);
   else