GksuProcess

GksuProcess

Synopsis

                    GksuProcessPrivate;
                    GksuProcess;
GType               gksu_process_get_type               (void);
#define             GKSU_TYPE_PROCESS
#define             GKSU_PROCESS                        (object)
#define             GKSU_PROCESS_GET_CLASS              (object)
GksuProcess*        gksu_process_new                    (const gchar *working_directory,
                                                         const gchar **arguments);
gboolean            gksu_process_spawn_async_with_pipes (GksuProcess *process,
                                                         gint *standard_input,
                                                         gint *standard_output,
                                                         gint *standard_error,
                                                         GError **error);
gboolean            gksu_process_spawn_async            (GksuProcess *process,
                                                         GError **error);
gboolean            gksu_process_spawn_sync             (GksuProcess *process,
                                                         gint *status,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GksuProcess

Signals

  "exited"                                         : Run Last

Description

Details

GksuProcessPrivate

typedef struct _GksuProcessPrivate GksuProcessPrivate;


GksuProcess

typedef struct _GksuProcess GksuProcess;


gksu_process_get_type ()

GType               gksu_process_get_type               (void);

Returns :


GKSU_TYPE_PROCESS

#define GKSU_TYPE_PROCESS (gksu_process_get_type())


GKSU_PROCESS()

#define GKSU_PROCESS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GKSU_TYPE_PROCESS, GksuProcess))

object :


GKSU_PROCESS_GET_CLASS()

#define GKSU_PROCESS_GET_CLASS(object)  (G_TYPE_INSTANCE_GET_CLASS ((object), GKSU_TYPE_PROCESS, GksuProcessClass))

object :


gksu_process_new ()

GksuProcess*        gksu_process_new                    (const gchar *working_directory,
                                                         const gchar **arguments);

This function creates a new GksuProcess object, which can be used to launch a process as the root user (uid 0). The process is started with the given directory path as its working directory. The arguments array must have the command to be executed at its first position, followed by the command's arguments; it must also contain a NULL at its last position.

working_directory :

directory path

arguments :

NULL-terminated array of strings

Returns :

a new instance of GksuProcess

gksu_process_spawn_async_with_pipes ()

gboolean            gksu_process_spawn_async_with_pipes (GksuProcess *process,
                                                         gint *standard_input,
                                                         gint *standard_output,
                                                         gint *standard_error,
                                                         GError **error);

Creates the process with the information stored in the GksuProcess. If you pass the pointers to integers to the standard_input, standard_output and standard_error parameters they will be set to the corresponding file descriptors of the child; the child standard I/O channels will be essentially disabled for the ones to which NULL is given.

This function return immediately after the process has been created. You need to connect to the GksuProcess::exited signal to know that the process has ended and get its exit status.

Notice that some caveats exist in how the input and output are handled. Gksu PolicyKit uses a D-Bus service to do the actual running of the program, and all the input must be sent to and all the output must be received from this service, through D-Bus. The library handles this, but it needs a glib main loop for that. This means that if you keep the mainloop from running by using a loop to read the standard output, for example, you may end up not having anything to read.

process :

standard_input :

return location for file descriptor to write to child's stdin, or NULL

standard_output :

return location for file descriptor to write to child's stdout, or NULL

standard_error :

return location for file descriptor to write to child's stderr, or NULL

error :

return location for a GError

Returns :

FALSE if error is set, TRUE if all went well

gksu_process_spawn_async ()

gboolean            gksu_process_spawn_async            (GksuProcess *process,
                                                         GError **error);

Creates the process with the information stored in the GksuProcess. This function will only return after the child process has finished.

Notice that, internally, this function runs the main loop, so even though this function will not return, idles, IO watches, timeouts, and event handlers may be called while the child is not yet finished.

process :

error :

return location for a GError

Returns :

FALSE if error is set, TRUE if all went well

gksu_process_spawn_sync ()

gboolean            gksu_process_spawn_sync             (GksuProcess *process,
                                                         gint *status,
                                                         GError **error);

process :

status :

error :

Returns :

Signal Details

The "exited" signal

void                user_function                      (GksuProcess *gksuprocess,
                                                        gint         arg1,
                                                        gpointer     user_data)        : Run Last

gksuprocess :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.