Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gdk::Spawn Class Reference

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

`#include <xfc/gdk/spawn.hh>`

Inheritance diagram for Xfc::Gdk::Spawn:

List of all members.

## Public Member Functions

Constructors

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

Accessors

- GPid child_pid () const
    Returns the child process ID or zero if an error occurs.

Methods

- bool execute (const Screen &screen, G::Error *error=0)
    Executes a child program asynchronously (that is, your program will not block waiting for the child to exit).
- bool execute (const Screen &screen, const ChildSetupSlot &slot, G::Error *error=0)
    Executes a child program asynchronously (that is, your program will not block waiting for the child to exit).
- bool execute (const Screen &screen, const ChildSetupSlot &slot, int *std_input, int *std_output, int *std_error, G::Error *error=0)
    Executes a child program asynchronously (that is, your program will not block waiting for the child to exit).

## Detailed Description

A C++ interface for the Gdk spawn functions.

Spawn executes a child program asynchronously like G::SpawnAsync except the child process is spawned in such an environment that on calling Gdk::Display::open() it would be returned a Gdk::Display with screen as the default screen. For more details see the G::SpawnAsync class documentation.

## Constructor & Destructor Documentation

Xfc::Gdk::Spawn::Spawn | ( | const std::vector< std::string > & | argv,
|  | G::SpawnFlagsField | flags = `0`
| ) |

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 child's argument strings.
  | flags | One or more bitflags from the G::SpawnFlags enumeration.

The first string in argv (argv[0]) is of course the name of the program to execute. By default, the name of the program must be a full path; the PATH shell variable will only be searched if you pass the G::SPAWN_SEARCH_PATH flag.

Xfc::Gdk::Spawn::Spawn | ( | const std::string & | command_line,
|  | G::Error * | error
| ) |

Constructs an asynchronous spawn object with the specified arguments in the command_line string.

Parameters:

  | command_line | The command line string.
  | error | The return location for a G::Error.

This constructor parses command line with g_shell_parse_argv() and passes it to GLib. If an error occurs it is set by the parsing function, and can be any of those from the G_SHELL_ERROR domain. Runs a command_line in the background. Unlike then other constructor, the G::SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note that G::SPAWN_SEARCH_PATH can have security implications, so consider using the other constructor if appropriate.

Reimplemented from Xfc::G::Spawn.

## Member Function Documentation

bool Xfc::Gdk::Spawn::execute | ( | const Screen & | screen,
|  | const ChildSetupSlot & | slot,
|  | int * | std_input,
|  | int * | std_output,
|  | int * | std_error,
|  | G::Error * | error = `0`
| ) |

Executes a child program asynchronously (that is, your program will not block waiting for the child to exit).

Parameters:

  | screen | A Gdk::Screen.
  | slot | A sigc::slot to call in the child just before exec().
  | std_input | The return location for the file descriptor to write to child's stdin.
  | std_output | The return location for the file descriptor to read child's stdout.
  | std_error | The return location for the file descriptor to read child's stderr.
  | error | The return location for a G::Error, or null to ignore errors.

Returns:
  true if successful, false if error is set.

The file descriptors std_input, std_output, and std_error are used for writing to the child's standard input or reading from its standard output or standard error, and must be closed by calling close() when no longer required.

If std_input is null the child's standard input is attached to /dev/null unless G::SPAWN_CHILD_INHERITS_STDIN is set. If std_error is null the child's standard error goes to the same location as the parent's standard error unless G::SPAWN_STDERR_TO_DEV_NULL is set. If std_output is not called the child's standard output goes to the same location as the parent's standard output unless G::SPAWN_STDOUT_TO_DEV_NULL is set.

bool Xfc::Gdk::Spawn::execute | ( | const Screen & | screen,
|  | const ChildSetupSlot & | slot,
|  | G::Error * | error = `0`
| ) |

Executes a child program asynchronously (that is, your program will not block waiting for the child to exit).

Parameters:

  | screen | A Gdk::Screen.
  | slot | A sigc::slot to call in the child just before exec().
  | error | The return location for a G::Error, or null to ignore errors.

Returns:
  true if successful, false if error is set.

bool Xfc::Gdk::Spawn::execute | ( | const Screen & | screen,
|  | G::Error * | error = `0`
| ) |

Executes a child program asynchronously (that is, your program will not block waiting for the child to exit).

Parameters:

  | screen | A Gdk::Screen.
  | error | The return location for a G::Error, or null to ignore errors.

Returns:
  true if successful, false if error is set.

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

- libXFCui/xfc/gdk/spawn.hh

Xfce Foundation Classes

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