~ubuntu-branches/ubuntu/raring/consolekit/raring

« back to all changes in this revision

Viewing changes to src/ck-vt-monitor.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-10-13 12:28:33 UTC
  • mfrom: (0.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20101013122833-i43tbcnvjs3jiynv
Tags: 0.4.2-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - 10-retry_console_open_eio.patch: Retry console opens if they return
    EIO, since this may happen while a tty is closing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <unistd.h>
27
27
#include <string.h>
28
28
#include <errno.h>
 
29
#include <signal.h>
29
30
 
30
31
#include <glib.h>
31
32
#include <glib/gi18n.h>
40
41
#include "ck-sysdeps.h"
41
42
#include "ck-marshal.h"
42
43
 
43
 
#if defined (__sun) && defined (HAVE_SYS_VT_H)
 
44
#ifdef HAVE_SYS_VT_H
44
45
#include <sys/vt.h>
45
 
#include <signal.h>
 
46
#endif
 
47
 
 
48
#ifdef __sun
46
49
#include <stropts.h>
47
50
#endif
48
51
 
163
166
        return TRUE;
164
167
}
165
168
 
166
 
#if defined (__sun) && defined (HAVE_SYS_VT_H)
 
169
#if defined(HAVE_SYS_VT_H) && defined(__sun)
167
170
static void
168
171
handle_vt_active (void)
169
172
{
313
316
{
314
317
        CkVtMonitor *vt_monitor;
315
318
        gboolean     res;
316
 
        gint32       num;
 
319
        guint        num;
317
320
 
318
321
        vt_monitor = data->vt_monitor;
319
322
        num = data->num;
320
323
 
 
324
#ifdef VT_WAITEVENT
 
325
        for (;;) {
 
326
                res = ck_wait_for_console_switch (vt_monitor->priv->vfd, &num);
 
327
                if (! res) {
 
328
                        break;
 
329
                } else {
 
330
                        EventData *event;
 
331
 
 
332
                        /* add event to queue */
 
333
                        event = g_new0 (EventData, 1);
 
334
                        event->num = num;
 
335
                        g_debug ("Pushing activation event for VT %d onto queue", num);
 
336
 
 
337
                        g_async_queue_push (vt_monitor->priv->event_queue, event);
 
338
 
 
339
                        /* schedule processing of queue */
 
340
                        schedule_process_queue (vt_monitor);
 
341
                }
 
342
        }
 
343
#else
321
344
        res = ck_wait_for_active_console_num (vt_monitor->priv->vfd, num);
322
345
        if (! res) {
323
346
                /* FIXME: what do we do if it fails? */
334
357
                /* schedule processing of queue */
335
358
                schedule_process_queue (vt_monitor);
336
359
        }
 
360
#endif
337
361
 
338
362
        G_LOCK (hash_lock);
339
363
        if (vt_monitor->priv->vt_thread_hash != NULL) {
377
401
static void
378
402
vt_add_watches (CkVtMonitor *vt_monitor)
379
403
{
380
 
        guint  max_consoles;
381
 
        int    i;
382
 
        gint32 current_num;
383
 
 
384
404
#if defined (__sun) && !defined (HAVE_SYS_VT_H)
385
405
        /* Best to do nothing if VT is not supported */
386
406
#elif defined (__sun) && defined (HAVE_SYS_VT_H)
393
413
         */
394
414
        struct sigaction act;
395
415
        act.sa_handler = handle_vt_active;
 
416
        sigemptyset (&act.sa_mask);
 
417
        act.sa_flags = 0;
396
418
        sigaction (SIGPOLL, &act, NULL);
397
419
 
398
420
        ioctl (vt_monitor->priv->vfd, I_SETSIG, S_MSG);
 
421
#elif defined (VT_WAITEVENT)
 
422
        gpointer id;
 
423
 
 
424
        G_LOCK (hash_lock);
 
425
        id = GINT_TO_POINTER (1);
 
426
        if (g_hash_table_lookup (vt_monitor->priv->vt_thread_hash, id) == NULL)
 
427
                vt_add_watch_unlocked (vt_monitor, 1);
 
428
        G_UNLOCK (hash_lock);
399
429
#else
 
430
        guint  max_consoles;
 
431
        int    i;
 
432
        gint32 current_num;
 
433
 
400
434
        G_LOCK (hash_lock);
401
435
 
402
436
        current_num = vt_monitor->priv->active_num;