## UDisksSpawnedJob UDisksSpawnedJob — Job that spawns a command |

## Functions

UDisksSpawnedJob * | udisks_spawned_job_new ()
const gchar * | udisks_spawned_job_get_command_line ()
void | udisks_spawned_job_start ()

## Properties

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

## Signals

gboolean | spawned-job-completed | Run Last

## Types and Values

| UDisksSpawnedJob

## Object Hierarchy

        GObject
        ╰── GDBusInterfaceSkeleton
            ╰── UDisksJobSkeleton
                ╰── UDisksBaseJob
                    ╰── UDisksSpawnedJob

## Implemented Interfaces

UDisksSpawnedJob implements GDBusInterface and UDisksJob.

## Description

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

## Functions

### udisks_spawned_job_new ()

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

Creates a new UDisksSpawnedJob instance.

The job is not started automatically! Use `udisks_spawned_job_start()` to start the job after “spawned-job-completed” or “completed” signals are connected (to get notified when the job is done). This is to prevent a race condition with the spawned process terminating before the signals are connected in which case the signal handlers are never triggered.

#### Parameters

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.

#### Parameters

job | A UDisksSpawnedJob. |

#### Returns

A string owned by `job` . Do not free.

### udisks_spawned_job_start ()

    void
    udisks_spawned_job_start (UDisksSpawnedJob *job);

## Types and Values

### UDisksSpawnedJob

    typedef struct _UDisksSpawnedJob UDisksSpawnedJob;

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

## Property Details

### The `“command-line”` property

      “command-line”             gchar *

The command-line to run.

Flags: Read / Write / Construct Only

Default value: NULL

### The `“input-string”` property

      “input-string”             AutowipeBuffer *

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

This is passed as autowipe_buffer (rather than G_TYPE_GSTRING) to nuke the contents after usage since the input string may contain key material.

Flags: Write / Construct Only

### The `“run-as-euid”` property

      “run-as-euid”              guint

The effective uid_t to run the program as.

Flags: Write / Construct Only

Default value: 0

### The `“run-as-uid”` property

      “run-as-uid”               guint

The uid_t to run the program as.

Flags: Write / Construct Only

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)

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.

#### Parameters

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.

Flags: Run Last