UDisksSpawnedJob

UDisksSpawnedJob — Job that spawns a command

Synopsis

                    UDisksSpawnedJob;
UDisksSpawnedJob *  udisks_spawned_job_new              (const gchar *command_line,
                                                         const gchar *input_string,
                                                         uid_t run_as_uid,
                                                         uid_t run_as_euid,
                                                         UDisksDaemon *daemon,
                                                         GCancellable *cancellable);
const gchar *       udisks_spawned_job_get_command_line (UDisksSpawnedJob *job);

Object Hierarchy

  GObject
   +----GDBusInterfaceSkeleton
         +----UDisksJobSkeleton
               +----UDisksBaseJob
                     +----UDisksSpawnedJob

Implemented Interfaces

UDisksSpawnedJob implements GDBusInterface and UDisksJob.

Properties

  "command-line"             gchar*                : Read / Write / Construct Only
  "input-string"             gchar*                : Write / Construct Only
  "run-as-euid"              guint                 : Write / Construct Only
  "run-as-uid"               guint                 : Write / Construct Only

Signals

  "spawned-job-completed"                          : Run Last

Description

This type provides an implementation of the UDisksJob interface for jobs that are implemented by spawning a command line.

Details

UDisksSpawnedJob

typedef struct _UDisksSpawnedJob UDisksSpawnedJob;

The UDisksSpawnedJob structure contains only private data and should only be accessed using the provided API.


udisks_spawned_job_new ()

UDisksSpawnedJob *  udisks_spawned_job_new              (const gchar *command_line,
                                                         const gchar *input_string,
                                                         uid_t run_as_uid,
                                                         uid_t run_as_euid,
                                                         UDisksDaemon *daemon,
                                                         GCancellable *cancellable);

Creates a new UDisksSpawnedJob instance.

The job is started immediately - connect to the "spawned-job-completed" or "completed" signals to get notified when the job is done.

command_line :

The command line to run.

input_string :

A string to write to stdin of the spawned program or NULL.

run_as_uid :

The uid_t to run the program as.

run_as_euid :

The effective uid_t to run the program as.

daemon :

A UDisksDaemon.

cancellable :

A GCancellable or NULL.

Returns :

A new UDisksSpawnedJob. Free with g_object_unref().

udisks_spawned_job_get_command_line ()

const gchar *       udisks_spawned_job_get_command_line (UDisksSpawnedJob *job);

Gets the command line that job was constructed with.

job :

A UDisksSpawnedJob.

Returns :

A string owned by job. Do not free.

Property Details

The "command-line" property

  "command-line"             gchar*                : Read / Write / Construct Only

The command-line to run.

Default value: NULL


The "input-string" property

  "input-string"             gchar*                : Write / Construct Only

String that will be written to stdin of the spawned program or NULL to not write anything.

Default value: NULL


The "run-as-euid" property

  "run-as-euid"              guint                 : Write / Construct Only

The effective uid_t to run the program as.

Default value: 0


The "run-as-uid" property

  "run-as-uid"               guint                 : Write / Construct Only

The uid_t to run the program as.

Default value: 0

Signal Details

The "spawned-job-completed" signal

gboolean            user_function                      (UDisksSpawnedJob *job,
                                                        GError           *error,
                                                        gint              status,
                                                        GString          *standard_output,
                                                        GString          *standard_error,
                                                        gpointer          user_data)            : Run Last

Emitted when the spawned job is complete. If spawning the command failed or if the job was cancelled, error will non-NULL. Otherwise you can use macros such as WIFEXITED() and WEXITSTATUS() on the status integer to obtain more information.

The default implementation simply emits the "completed" signal with success set to TRUE if, and only if, error is NULL, WIFEXITED() evaluates to TRUE and WEXITSTATUS() is zero. Additionally, message on that signal is set to standard_error regards of whether success is TRUE or FALSE.

You can avoid the default implementation by returning TRUE from your signal handler.

This signal is emitted in the thread-default main loop of the thread that job was created in.

job :

The UDisksSpawnedJob emitting the signal.

error :

NULL if running the whole command line succeeded, otherwise a GError that is set.

status :

The exit status of the command line that was run.

standard_output :

Standard output from the command line that was run.

standard_error :

Standard error output from the command line that was run.

user_data :

user data set when the signal handler was connected.

Returns :

TRUE if the signal was handled, FALSE to let other handlers run.