glib-sharp
2.12.0.0
System.Object
Field
System.Int32
2147483647
IgnorePipe field.
Pass this value to to ignore a pipe parameter.
Field
System.Int32
0
RequestPipe field.
Pass this value to to request a request a pipe descriptor be returned in the parameter.
Method
System.Boolean
The command line with arguments.
Spawns a child process asynchronously.
A boolean value indicating spawning success.
This method does not wait for the child process to complete before returning. It is a convenience method for the more detailed method.
...
try {
GLib.Process.SpawnCommandLineAsync ("echo \"[Async echo process running]\"");
} catch (GException e) {
Console.WriteLine ("Exception in Spawn operation: " + e);
}
...
Method
System.Boolean
The command line with arguments.
Returns the stdout output of the child process as a string.
Returns the stderr output of the child process as a string.
Returns the exit code returned by the process.
Spawns a child process synchronously.
A boolean value indicating spawning success.
The method waits for the child process to complete prior to returning. This is a convenience method for the more detailed method.
...
try {
string stdout, stderr;
int exit_status;
GLib.Process.SpawnCommandLineSync ("pwd", out stdout, out stderr, out exit_status);
Console.Write ("pwd exit_status=" + exit_status + " output: " + stdout);
} catch (GException e) {
Console.WriteLine ("Exception in Spawn operation: " + e);
}
...
Method
System.Boolean
The directory in which to execute the process, or to use the current directory of the parent process.
A string array containing the program name in the first element.
An array of environment values in the form 'var=value', or .
Process spawning configuration flags.
A child process setup callback, or .
Returns the stdout output of the child process as a string.
Returns the stderr output of the child process as a string.
Returns the exit code of the child process.
Spawns a child process synchronously.
A boolean value indicating spawning success.
The method waits for the child process to complete prior to returning.
...
try {
string stdout, stderr;
int exit_status;
GLib.Process.SpawnSync ("/usr", new string[] {"pwd"}, null, GLib.SpawnFlags.SearchPath, null, out stdout, out stderr, out exit_status);
Console.Write ("pwd exit_status=" + exit_status + " output: " + stdout);
} catch (GException e) {
Console.WriteLine ("Exception in Spawn operation: " + e);
}
...
Method
System.Void
Closes a process.
Processes spawned with must use this method to ensure zombie processes are not stranded.
Method
System.Boolean
The directory in which to execute the process, or to use the current directory of the parent process.
A string array containing the program name in the first element.
An array of environment values in the form 'var=value', or .
Process spawning configuration flags.
A child process setup callback, or .
Returns the child process.
Spawns a child process asynchronously.
A boolean value indicating spawning success.
The method does not wait for the child process to complete before returning. This is a convenience method for the more detailed method. This method throws if an error occurs creating the process.
...
try {
GLib.Process proc;
GLib.Process.SpawnAsync (null, new string[] {"echo", "[Async echo is running]"}, null, GLib.SpawnFlags.SearchPath, null, out proc);
} catch (GException e) {
Console.WriteLine ("Exception in Spawn operation: " + e);
}
...
Method
System.Boolean
The directory in which to execute the process, or to use the current directory of the parent process.
A string array containing the program name in the first element.
An array of environment values in the form 'var=value', or .
Process spawning configuration flags.
A child process setup callback, or .
Returns the spawned process.
Returns the stdin pipe descriptor if caller passes anything but .
Returns the stdout pipe descriptor if caller passes anything but .
Returns the stderr pipe descriptor if caller passes anything but .
Spawns a child process and returns requested pipe descriptors.
A boolean value indicating operation success.
This method throws if an error occurs creating the process.
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;
}
}
Process class.
Methods for spawning child processes.