Xfce Foundation Classes
Main Page | Index | Namespace 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:

List of all members.

## Public Types

- typedef sigc::slot< void > ChildSetupSlot
    Signature of the callback slot to be called after GLib has performed all the setup it plans to perform but before calling exec().

## Public Member Functions

Methods

- void set_working_directory (const std::string &working_directory)
    Sets the child's current working directory.
- void set_enviroment (std::vector< std::string > &envp)
    Sets the child's enviroment.

## Static Public Member Functions

Methods

- void close_pid (GPid pid)
    Closes the process identified by pid.

## Protected Member Functions

Constructors

- Spawn (const std::vector< std::string > &argv, SpawnFlagsField flags)
    Constructs an asynchronous spawn object with the specified arguments argv and spawn flags.
- Spawn (const std::string &command_line, G::Error *error)
    Constructs a new spawn object with the specified arguments in the command_line string.
- virtual ~Spawn ()
    Destructor.

Accessors

- const char * get_working_directory () const
    Returns the current working directory, or null.
- char ** get_argv () const
    Returns a pointer to the argument array to pass to the child, or null.
- char ** get_envp () const
    Returns a pointer to the enviroment array to pass to the child, or null.
- GSpawnFlags get_flags () const
    Returns the flags to pass to the child process spawned.

## 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.

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::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.

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.

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.

The documentation for this class was generated from the following file:

- libXFCcore/xfc/glib/spawn.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3