libgpg-error: fix riscv64
[openadk.git] / package / sash / src / reboot.c
blob479673a359c104d71997dbb024deb53ac49bdba3
1 /* shutdown.c:
3 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * JUN/99 -- copied from shutdown.c to make new reboot command.
11 * (gerg@snapgear.com)
12 * AUG/99 -- added delay option to reboot
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <string.h>
18 #include <fcntl.h>
19 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <dirent.h>
23 #include <pwd.h>
24 #include <grp.h>
25 #include <time.h>
26 #include <signal.h>
27 #include <unistd.h>
29 #include <getopt.h>
30 #include <sys/reboot.h>
32 int main(int argc, char *argv[])
34 int delay = 0; /* delay in seconds before rebooting */
35 int rc;
36 int force = 0;
38 while ((rc = getopt(argc, argv, "h?d:f")) > 0) {
39 switch (rc) {
40 case 'd':
41 delay = atoi(optarg);
42 break;
43 case 'f':
44 force = 1;
45 break;
46 case 'h':
47 case '?':
48 default:
49 printf("usage: reboot [-h] [-d <delay>] [-f]\n");
50 exit(0);
51 break;
55 if(delay > 0)
56 sleep(delay);
58 kill(1, SIGTSTP);
59 sync();
60 signal(SIGTERM,SIG_IGN);
61 signal(SIGHUP,SIG_IGN);
62 setpgrp();
63 kill(-1, SIGTERM);
64 sleep(1);
65 kill(-1, SIGHUP);
66 sleep(1);
67 sync();
68 sleep(1);
69 reboot(0x01234567);
70 exit(0); /* Shrug */