OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [userland/] [sash/] [reboot.c] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* shutdown.c:
2
 *
3
 * Copyright (C) 1998  Kenneth Albanowski <kjahds@kjahds.com>,
4
 *
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.
9
 *
10
 * JUN/99 -- copied from shutdown.c to make new reboot command.
11
 *           (gerg@lineo.com)
12
 * AUG/99 -- added delay option to reboot
13
 */
14
 
15
#include <linux/autoconf.h>
16
 
17
#include <string.h>
18
#include <fcntl.h>
19
#include <sys/types.h>
20
 
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
 
28
#include <getopt.h>
29
 
30
int main(int argc, char *argv[])
31
{
32
        int delay = 0; /* delay in seconds before rebooting */
33
        int rc;
34
 
35
        while ((rc = getopt(argc, argv, "h?d:")) > 0) {
36
                switch (rc) {
37
                case 'd':
38
                        delay = atoi(optarg);
39
                        break;
40
                case 'h':
41
                case '?':
42
                default:
43
                        printf("usage: reboot [-h] [-d <delay>]\n");
44
                        exit(0);
45
                        break;
46
                }
47
        }
48
 
49
        if(delay > 0)
50
                sleep(delay);
51
#ifdef CONFIG_DISKtel
52
        printf("unmounting /home\n");
53
        if(umount("/home") != 0){
54
                printf("unmounting failed!!!\n");
55
        }
56
#endif
57
 
58
        kill(1, SIGTSTP);
59
        sync();
60
        signal(SIGTERM,SIG_IGN);
61
        setpgrp();
62
        kill(-1, SIGTERM);
63
        sleep(1);
64
        kill(-1, SIGHUP);
65
        sleep(1);
66
        kill(-1, SIGKILL);
67
        sync();
68
        sleep(1);
69
        reboot(0xfee1dead, 672274793, 0x01234567);
70
        exit(0); /* Shrug */
71
}
72
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.