removed some verbose messages
[minix3.git] / commands / reboot / tinyhalt.c
blob80ce03f046549f4071178865f72d6f193d4ac02e
1 /* tinyhalt 1.0 - small forerunner Author: Kees J. Bot
3 * Disk space on the root file system is a scarce resource. This little
4 * program sits in /sbin. It normally calls the real halt/reboot, but if
5 * that isn't available then it simply calls reboot(). Can't do any logging
6 * of the event anyhow.
7 */
8 #define nil 0
9 #include <sys/types.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <fcntl.h>
13 #include <unistd.h>
14 #include <signal.h>
16 int main(int argc, char **argv)
18 int flag;
19 char *prog;
20 char *reboot_code = "delay; boot";
22 /* Try to run the real McCoy. */
23 #if __minix_vmd
24 execv("/usr/sbin/halt", argv);
25 #else
26 execv("/usr/bin/halt", argv);
27 #endif
29 if ((prog = strrchr(*argv,'/')) == nil) prog= argv[0]; else prog++;
31 sleep(1); /* Not too fast. */
32 signal(SIGHUP, SIG_IGN);
33 signal(SIGTERM, SIG_IGN);
34 kill(1, SIGTERM);
35 kill(-1, SIGTERM);
36 sleep(1);
38 reboot(strcmp(prog, "reboot") == 0 ? RBT_MONITOR : RBT_HALT,
39 reboot_code, strlen(reboot_code));
41 write(2, "reboot call failed\n", 19);
42 return 1;