Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::G::Spawn Class Reference

A C++ interface for the GLib spawn functions. More...

#include <xfc/glib/spawn.hh>

Inheritance diagram for Xfc::G::Spawn:

Xfc::StackObject Xfc::G::SpawnAsync Xfc::G::SpawnSync Xfc::Gdk::Spawn List of all members.

Public Types

Public Member Functions

Methods

Static Public Member Functions

Methods

Protected Member Functions

Accessors

Detailed Description

A C++ interface for the GLib spawn functions.

Rather than wrap the GLib spawn functions individually XFC wraps these functions into two easy to use classes: SpawnAsync and SpawnSync. SpawnAync executes a child program asynchronously (your program will not block waiting for the child to exit) and SpawnSync executes a child synchronously (your program waits for the child to exit before returning).

Spawn is just a convenient base class that implements the code common to both SpawnAsync and SpawnSync. It derives from StackObject so you can only create SpawnAsync and SpawnSync on the stack. Spawn has only two public methods that can be called: set_working_directory() and set_enviroment(). You call set_working_directory() to set the child's current working directory and you call set_enviroment() to set the child's environment. If you call neither of these methods the child will inherit its parent's working directory and enviroment.


Member Typedef Documentation

typedef sigc::slot<void> Xfc::G::Spawn::ChildSetupSlot

Signature of the callback slot to be called after GLib has performed all the setup it plans to perform but before calling exec().

Example: Method signature for ChildSetupSlot.

< void method();
<

Obviously, actions taken in this method will only affect the child, not the parent.


Constructor & Destructor Documentation

Xfc::G::Spawn::Spawn ( const std::vector< std::string > &  argv,
SpawnFlagsField  flags 
) [protected]

Constructs an asynchronous spawn object with the specified arguments argv and spawn flags.

Parameters:
argv A reference to a vector of std::string that holds the argument strings.
flags The G::SpawnFlags to set.

Reimplemented in Xfc::Gdk::Spawn.

Xfc::G::Spawn::Spawn ( const std::string &  command_line,
G::Error error 
) [protected]

Constructs a new spawn object with the specified arguments in the command_line string.

Parameters:
command_line A command line.
error The return location for a G::Error.
This method sets the G_SPAWN_SEARCH_PATH flags and unsets all others.

Reimplemented in Xfc::Gdk::Spawn.

Xfc::G::Spawn::Spawn ( const std::vector< std::string > &  argv,
SpawnFlagsField  flags 
) [protected]

Constructs an asynchronous spawn object with the specified arguments argv and spawn flags.

Parameters:
argv A reference to a vector of std::string that holds the argument strings.
flags The G::SpawnFlags to set.

Reimplemented in Xfc::Gdk::Spawn.

Xfc::G::Spawn::Spawn ( const std::string &  command_line,
G::Error error 
) [protected]

Constructs a new spawn object with the specified arguments in the command_line string.

Parameters:
command_line A command line.
error The return location for a G::Error.
This method sets the G_SPAWN_SEARCH_PATH flags and unsets all others.

Reimplemented in Xfc::Gdk::Spawn.


Member Function Documentation

void Xfc::G::Spawn::set_working_directory ( const std::string &  working_directory  ) 

Sets the child's current working directory.

Parameters:
working_directory The working directory to set.
If not specifically set a child will inherit its parent's working directory.

void Xfc::G::Spawn::set_enviroment ( std::vector< std::string > &  envp  ) 

Sets the child's enviroment.

Parameters:
envp A reference to a vector of std::string that holds the child's enviroment strings.
Each string in the vector must has the form KEY=VALUE. This will become the child's environment. If not specifically set a child will inherit its parent's enviroment.

static void Xfc::G::Spawn::close_pid ( GPid  pid  )  [static]

Closes the process identified by pid.

Parameters:
pid The process identifier to close.
On some platforms, notably WIN32, the GPid type represents a resource which must be closed to prevent resource leaking. close_pid() is provided for this purpose. It should be used on all platforms, even though it doesn't do anything under UNIX.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3