octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: async "system" under Win32


From: John W. Eaton
Subject: Patch: async "system" under Win32
Date: Wed, 3 Jan 2007 13:23:30 -0500

On  3-Jan-2007, address@hidden wrote:

| The attached patch implements async \"system\" under plain Win32.

OK, but I did it this way since I think it's generally not good to
cast away const.

Thanks,

jwe

Index: src/toplev.cc
===================================================================
RCS file: /cvs/octave/src/toplev.cc,v
retrieving revision 1.190
diff -u -u -r1.190 toplev.cc
--- src/toplev.cc       28 Oct 2006 16:30:52 -0000      1.190
+++ src/toplev.cc       3 Jan 2007 18:13:49 -0000
@@ -542,6 +542,7 @@
        {
          if (type == et_async)
            {
+             // FIXME -- maybe this should go in sysdep.cc?
 #ifdef HAVE_FORK
              pid_t pid = fork ();
 
@@ -559,6 +560,22 @@
                }
              else
                retval(0) = pid;
+#elif defined (__WIN32__)
+              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");
+              else
+                {
+                  retval(0) = pi.dwProcessId;
+                  CloseHandle (pi.hProcess);
+                  CloseHandle (pi.hThread);
+                }
 #else
              error ("asynchronous system calls are not supported");
 #endif

reply via email to

[Prev in Thread] Current Thread [Next in Thread]