~robert-ancell/lightdm/private-mir-connection-merge

« back to all changes in this revision

Viewing changes to tests/src/test-session.c

  • Committer: Robert Ancell
  • Date: 2013-07-23 02:24:45 UTC
  • mfrom: (1723 trunk)
  • mto: This revision was merged to the branch mainline in revision 1741.
  • Revision ID: robert.ancell@canonical.com-20130723022445-gpaq8vtkp4hods7r
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <stdlib.h>
2
2
#include <stdio.h>
3
3
#include <string.h>
4
 
#include <signal.h>
5
4
#include <sys/types.h>
6
5
#include <unistd.h>
7
6
#include <fcntl.h>
10
9
#include <glib.h>
11
10
#include <glib-object.h>
12
11
#include <gio/gio.h>
 
12
#include <glib-unix.h>
13
13
 
14
14
#include "status.h"
15
15
 
23
23
 
24
24
static xcb_connection_t *connection;
25
25
 
26
 
static void
27
 
quit_cb (int signum)
28
 
{
29
 
    status_notify ("%s TERMINATE SIGNAL=%d", session_id, signum);
30
 
    exit (EXIT_SUCCESS);
 
26
static gboolean
 
27
sigint_cb (gpointer user_data)
 
28
{
 
29
    status_notify ("%s TERMINATE SIGNAL=%d", session_id, SIGINT);
 
30
    g_main_loop_quit (loop);
 
31
    return TRUE;
 
32
}
 
33
 
 
34
static gboolean
 
35
sigterm_cb (gpointer user_data)
 
36
{
 
37
    status_notify ("%s TERMINATE SIGNAL=%d", session_id, SIGTERM);
 
38
    g_main_loop_quit (loop);
 
39
    return TRUE;
31
40
}
32
41
 
33
42
static void
179
188
    if (g_str_has_suffix (open_fds->str, ","))
180
189
        open_fds->str[strlen (open_fds->str) - 1] = '\0';
181
190
 
182
 
    signal (SIGINT, quit_cb);
183
 
    signal (SIGTERM, quit_cb);
184
 
 
185
191
#if !defined(GLIB_VERSION_2_36)
186
192
    g_type_init ();
187
193
#endif
188
194
 
189
195
    loop = g_main_loop_new (NULL, FALSE);
190
196
 
 
197
    g_unix_signal_add (SIGINT, sigint_cb, NULL);
 
198
    g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
 
199
 
191
200
    status_connect (request_cb);
192
201
 
193
202
    if (argc > 1)