Back to index

lightdm  1.3.2
Classes | Defines | Typedefs | Functions
process.h File Reference
#include <glib-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Process
struct  ProcessClass

Defines

#define PROCESS_TYPE   (process_get_type())
#define PROCESS_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), PROCESS_TYPE, ProcessClass))
#define PROCESS(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROCESS_TYPE, Process))
#define PROCESS_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), PROCESS_TYPE, ProcessClass))

Typedefs

typedef struct ProcessPrivate

Functions

GType process_get_type (void)
Processprocess_get_current (void)
Processprocess_new (void)
void process_set_clear_environment (Process *process, gboolean clear_environment)
gboolean process_get_clear_environment (Process *process)
void process_set_env (Process *process, const gchar *name, const gchar *value)
const gchar * process_get_env (Process *process, const gchar *name)
void process_set_command (Process *process, const gchar *command)
const gchar * process_get_command (Process *process)
gboolean process_start (Process *process)
gboolean process_get_is_running (Process *process)
GPid process_get_pid (Process *process)
void process_signal (Process *process, int signum)
void process_stop (Process *process)
void process_wait (Process *process)
int process_get_exit_status (Process *process)

Class Documentation

struct Process

Definition at line 26 of file process.h.

Collaboration diagram for Process:
Class Members
guint kill_timeout
GObject parent_instance
pid_t pid
ProcessPrivate * priv

Define Documentation

#define PROCESS (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROCESS_TYPE, Process))

Definition at line 21 of file process.h.

#define PROCESS_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PROCESS_TYPE, ProcessClass))

Definition at line 20 of file process.h.

#define PROCESS_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PROCESS_TYPE, ProcessClass))

Definition at line 22 of file process.h.

#define PROCESS_TYPE   (process_get_type())

Definition at line 19 of file process.h.


Typedef Documentation

typedef struct ProcessPrivate

Definition at line 24 of file process.h.


Function Documentation

gboolean process_get_clear_environment ( Process process)

Definition at line 87 of file process.c.

{
    g_return_val_if_fail (process != NULL, FALSE);
    return process->priv->clear_environment;
}
const gchar* process_get_command ( Process process)

Definition at line 119 of file process.c.

{
    g_return_val_if_fail (process != NULL, NULL);
    return process->priv->command;
}

Definition at line 62 of file process.c.

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* process_get_env ( Process process,
const gchar *  name 
)

Definition at line 102 of file process.c.

{
    g_return_val_if_fail (process != NULL, NULL);
    g_return_val_if_fail (name != NULL, NULL);
    return g_hash_table_lookup (process->priv->env, name);
}
int process_get_exit_status ( Process process)

Definition at line 265 of file process.c.

{
    g_return_val_if_fail (process != NULL, -1);
    return process->priv->exit_status;
}

Here is the caller graph for this function:

gboolean process_get_is_running ( Process process)

Definition at line 208 of file process.c.

{
    g_return_val_if_fail (process != NULL, FALSE);
    return process->priv->pid != 0;
}
GPid process_get_pid ( Process process)

Definition at line 215 of file process.c.

{
    g_return_val_if_fail (process != NULL, 0);
    return process->priv->pid;
}

Here is the caller graph for this function:

GType process_get_type ( void  )
Process* process_new ( void  )

Definition at line 74 of file process.c.

{
    return g_object_new (PROCESS_TYPE, NULL);
}

Here is the caller graph for this function:

void process_set_clear_environment ( Process process,
gboolean  clear_environment 
)

Definition at line 80 of file process.c.

{
    g_return_if_fail (process != NULL);
    process->priv->clear_environment = clear_environment;
}

Here is the caller graph for this function:

void process_set_command ( Process process,
const gchar *  command 
)

Definition at line 110 of file process.c.

{
    g_return_if_fail (process != NULL);

    g_free (process->priv->command);
    process->priv->command = g_strdup (command);
}

Here is the caller graph for this function:

void process_set_env ( Process process,
const gchar *  name,
const gchar *  value 
)

Definition at line 94 of file process.c.

{
    g_return_if_fail (process != NULL);
    g_return_if_fail (name != NULL);
    g_hash_table_insert (process->priv->env, g_strdup (name), g_strdup (value));  
}

Here is the caller graph for this function:

void process_signal ( Process process,
int  signum 
)

Definition at line 222 of file process.c.

{
    g_return_if_fail (process != NULL);

    if (process->priv->pid == 0)
        return;

    g_debug ("Sending signal %d to process %d", signum, process->priv->pid);

    if (kill (process->priv->pid, signum) < 0)
        g_warning ("Error sending signal %d to process %d: %s", signum, process->priv->pid, strerror (errno));
}

Here is the caller graph for this function:

gboolean process_start ( Process process)

Definition at line 179 of file process.c.

{
    pid_t pid;

    g_return_val_if_fail (process != NULL, FALSE);
    g_return_val_if_fail (process->priv->command != NULL, FALSE);  
    g_return_val_if_fail (process->priv->pid == 0, FALSE);

    pid = fork ();
    if (pid < 0)
    {
        g_warning ("Failed to fork: %s", strerror (errno));
        return FALSE;
    }

    if (pid == 0)
        g_signal_emit (process, signals[RUN], 0);

    g_debug ("Launching process %d: %s", pid, process->priv->command);

    process->priv->pid = pid;

    g_hash_table_insert (processes, GINT_TO_POINTER (process->priv->pid), g_object_ref (process));
    g_child_watch_add (process->priv->pid, process_watch_cb, process);

    return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void process_stop ( Process process)

Definition at line 244 of file process.c.

{
    g_return_if_fail (process != NULL);

    /* Send SIGTERM, and then SIGKILL if no response */
    process->priv->quit_timeout = g_timeout_add (5000, (GSourceFunc) quit_timeout_cb, process);
    process_signal (process, SIGTERM);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void process_wait ( Process process)

Definition at line 254 of file process.c.

{
    int exit_status;

    g_return_if_fail (process != NULL);

    waitpid (process->priv->pid, &exit_status, 0);
    process_watch_cb (process->priv->pid, exit_status, process);
}

Here is the call graph for this function:

Here is the caller graph for this function: