public static bool SpawnAsyncWithPipes (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process, ref int stdin, ref int stdout, ref int stderr) { int pid; IntPtr error; IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory); IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv); IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp); SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup); IntPtr in_ptr = stdin == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4); IntPtr out_ptr = stdout == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4); IntPtr err_ptr = stderr == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4); bool result = g_spawn_async_with_pipes (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, in_ptr, out_ptr, err_ptr, out error); child_process = new Process (pid); if (in_ptr != IntPtr.Zero) { stdin = Marshal.ReadInt32 (in_ptr); Marshal.FreeHGlobal (in_ptr); } if (out_ptr != IntPtr.Zero) { stdout = Marshal.ReadInt32 (out_ptr); Marshal.FreeHGlobal (out_ptr); } if (err_ptr != IntPtr.Zero) { stderr = Marshal.ReadInt32 (err_ptr); Marshal.FreeHGlobal (err_ptr); } Marshaller.Free (native_dir); Marshaller.Free (native_argv); Marshaller.Free (native_envp); if (error != IntPtr.Zero) throw new Gst.GLib.GException (error); return result; }
public static bool SpawnSync (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out string stdout, out string stderr, out int exit_status) { IntPtr native_stdout, native_stderr, error; IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory); IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv); IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp); SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup); bool result = g_spawn_sync (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error); Marshaller.Free (native_dir); Marshaller.Free (native_argv); Marshaller.Free (native_envp); stdout = Marshaller.PtrToStringGFree (native_stdout); stderr = Marshaller.PtrToStringGFree (native_stderr); if (error != IntPtr.Zero) throw new Gst.GLib.GException (error); return result; }
public static bool SpawnAsync (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process) { int pid; IntPtr error; IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory); IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv); IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp); SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup); bool result = g_spawn_async (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, out error); child_process = new Process (pid); Marshaller.Free (native_dir); Marshaller.Free (native_argv); Marshaller.Free (native_envp); if (error != IntPtr.Zero) throw new Gst.GLib.GException (error); return result; }