- working_directory
- The directory in which to execute the process, or null to use the current directory of the parent process.
- argv
- A string array containing the program name in the first element.
- envp
- An array of environment values in the form 'var=value', or null.
- flags
- Process spawning configuration flags.
- child_setup
- A child process setup callback, or null.
- child_process
- Returns the spawned process.
- stdin
- Returns the stdin pipe descriptor if caller passes anything but ib.Process.IgnorePipe.
- stdout
- Returns the stdout pipe descriptor if caller passes anything but ib.Process.IgnorePipe.
- stderr
- Returns the stderr pipe descriptor if caller passes anything but ib.Process.IgnorePipe.
A boolean value indicating operation success.
This method throws GLib.GException if an error occurs creating the process.
C# Example
using GLib;
using System;
public class SpawnTest {
public static void Main (string[] args)
{
new SpawnTest ();
}
MainLoop main_loop;
IOChannel channel;
public SpawnTest ()
{
main_loop = new MainLoop ();
try {
Process proc;
int stdin = Process.IgnorePipe;
int stdout = Process.RequestPipe;
int stderr = Process.IgnorePipe;
GLib.Process.SpawnAsyncWithPipes (null, new string[] {"pwd"}, null, SpawnFlags.SearchPath, null, out proc, ref stdin, ref stdout, ref stderr);
channel = new IOChannel (stdout);
channel.AddWatch (0, IOCondition.In | IOCondition.Hup, new IOFunc (ReadStdout));
} catch (Exception e) {
Console.WriteLine ("Exception in Spawn: " + e);
}
main_loop.Run ();
}
bool ReadStdout (IOChannel source, IOCondition condition)
{
if ((condition & IOCondition.In) == IOCondition.In) {
string txt;
if (source.ReadToEnd (out txt) == IOStatus.Normal)
Console.WriteLine ("[SpawnTest output] " + txt);
}
if ((condition & IOCondition.Hup) == IOCondition.Hup) {
source.Dispose ();
main_loop.Quit ();
return true;
}
return true;
}
}