~jamesodhunt/upstart/test-quiesce-cleanup

« back to all changes in this revision

Viewing changes to util/shutdown.c

  • Committer: Scott James Remnant
  • Date: 2009-07-08 19:43:16 UTC
  • Revision ID: scott@netsplit.com-20090708194316-t6rw4e8auuza6qju
* conf/control-alt-delete.conf: Default job for Control-Alt-Delete
* conf/rc-sysinit.conf: Default job for system initialisation
* conf/rc.conf: A fully wacky instance job that runs the rc script
for runlevel changes
* conf/rcS.conf: And a job for single-user-mode, which calls back
to rc-sysinit
* conf/Makefile.am (dist_init_DATA): Install the default files
into the /etc/init directory
* configure.ac (AC_CONFIG_FILES): Create conf/Makefile
* Makefile.am (SUBDIRS): Recurse into the conf directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* upstart
2
2
 *
3
 
 * Copyright © 2010 Canonical Ltd.
 
3
 * Copyright © 2009 Canonical Ltd.
4
4
 * Author: Scott James Remnant <scott@netsplit.com>.
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
80
80
#define DEV_INITCTL "/dev/initctl"
81
81
#endif
82
82
 
83
 
/**
84
 
 * RUN_INITCTL:
85
 
 *
86
 
 * System V init control socket (new location).
87
 
 **/
88
 
#ifndef RUN_INITCTL
89
 
#define RUN_INITCTL "/run/initctl"
90
 
#endif
91
83
 
92
84
/* Prototypes for option functions */
93
85
static int runlevel_option (NihOption *option, const char *arg);
405
397
 
406
398
 
407
399
        /* Give us a sane environment */
408
 
        if (chdir ("/") < 0)
409
 
                nih_warn ("%s: %s", _("Unable to change directory"),
410
 
                          strerror (errno));
 
400
        chdir ("/");
411
401
        umask (022);
412
402
 
413
403
        /* Shutdown now? */
467
457
{
468
458
        nih_local char **extra_env = NULL;
469
459
        NihDBusError *   dbus_err;
470
 
        int              exit_val = 0;
471
460
 
472
461
        if (init_halt) {
473
462
                char *e;
484
473
                if ((dbus_err->number != NIH_DBUS_ERROR)
485
474
                    || strcmp (dbus_err->name, DBUS_ERROR_NO_SERVER)) {
486
475
                        nih_fatal ("%s", dbus_err->message);
487
 
                        nih_free (dbus_err);
488
476
                        exit (1);
489
477
                }
490
478
 
495
483
                 * yet rebooted ... so try /dev/initctl
496
484
                 */
497
485
                sysvinit_shutdown ();
498
 
                nih_fatal ("Unable to shutdown system");
499
 
                exit_val = 1;
500
486
        }
501
487
 
502
488
        unlink (ETC_NOLOGIN);
503
489
        nih_main_unlink_pidfile ();
504
490
 
505
 
        exit (exit_val);
 
491
        exit (0);
506
492
}
507
493
 
508
494
/**
827
813
        sigemptyset (&act.sa_mask);
828
814
        sigaction (SIGALRM, &act, NULL);
829
815
 
 
816
        /* Try and open /dev/initctl */
830
817
        alarm (3);
831
 
        /* Try and open /run/initctl */
832
 
        fd = open (RUN_INITCTL, O_WRONLY | O_NDELAY | O_NOCTTY);
833
 
        if (fd < 0) {
834
 
                /* Fall back to /dev/initctl */
835
 
                fd = open (DEV_INITCTL, O_WRONLY | O_NDELAY | O_NOCTTY);
836
 
        }
 
818
        fd = open (DEV_INITCTL, O_WRONLY | O_NDELAY | O_NOCTTY);
837
819
        if (fd >= 0) {
838
820
                if (write (fd, &request, sizeof (request)) == sizeof (request))
839
821
                        exit (0);