Last change
on this file since 1841 was 821, checked in by Bruno Cornec, 18 years ago |
Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)
|
File size:
1.4 KB
|
Line | |
---|
1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * Stuff shared between init, reboot, halt, and poweroff
|
---|
4 | *
|
---|
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
---|
6 | *
|
---|
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include "busybox.h"
|
---|
11 | #include <signal.h>
|
---|
12 | #include <stdlib.h>
|
---|
13 | #include <sys/types.h>
|
---|
14 | #include <unistd.h>
|
---|
15 | #include <getopt.h>
|
---|
16 | #include <sys/reboot.h>
|
---|
17 | #include <sys/syslog.h>
|
---|
18 | #include "init_shared.h"
|
---|
19 |
|
---|
20 | const char * const init_sending_format = "Sending SIG%s to all processes.";
|
---|
21 | #ifndef CONFIG_INIT
|
---|
22 | const char * const bb_shutdown_format = "\r%s\n";
|
---|
23 | int bb_shutdown_system(unsigned long magic)
|
---|
24 | {
|
---|
25 | int pri = LOG_KERN|LOG_NOTICE|LOG_FACMASK;
|
---|
26 | const char *message;
|
---|
27 |
|
---|
28 | /* Don't kill ourself */
|
---|
29 | signal(SIGTERM,SIG_IGN);
|
---|
30 | signal(SIGHUP,SIG_IGN);
|
---|
31 | bb_setpgrp;
|
---|
32 |
|
---|
33 | /* Allow Ctrl-Alt-Del to reboot system. */
|
---|
34 | #ifndef RB_ENABLE_CAD
|
---|
35 | #define RB_ENABLE_CAD 0x89abcdef
|
---|
36 | #endif
|
---|
37 | reboot(RB_ENABLE_CAD);
|
---|
38 |
|
---|
39 | openlog(bb_applet_name, 0, pri);
|
---|
40 |
|
---|
41 | message = "\nThe system is going down NOW !!";
|
---|
42 | syslog(pri, "%s", message);
|
---|
43 | printf(bb_shutdown_format, message);
|
---|
44 |
|
---|
45 | sync();
|
---|
46 |
|
---|
47 | /* Send signals to every process _except_ pid 1 */
|
---|
48 | message = "TERM";
|
---|
49 | syslog(pri, init_sending_format, message);
|
---|
50 | printf(bb_shutdown_format, message);
|
---|
51 |
|
---|
52 | kill(-1, SIGTERM);
|
---|
53 | sleep(1);
|
---|
54 | sync();
|
---|
55 |
|
---|
56 | message = "KILL";
|
---|
57 | syslog(pri, init_sending_format, message);
|
---|
58 | printf(bb_shutdown_format, message);
|
---|
59 |
|
---|
60 | kill(-1, SIGKILL);
|
---|
61 | sleep(1);
|
---|
62 |
|
---|
63 | sync();
|
---|
64 |
|
---|
65 | reboot(magic);
|
---|
66 | return 0; /* Shrug */
|
---|
67 | }
|
---|
68 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.