From 8e2707b81b0c90295c9fdf92a576925442d22147 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 20 Aug 2014 21:11:13 +0200 Subject: add sash, simpleinit and a uclibc config for nonmmu case --- package/sash/src/shutdown.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 package/sash/src/shutdown.c (limited to 'package/sash/src/shutdown.c') diff --git a/package/sash/src/shutdown.c b/package/sash/src/shutdown.c new file mode 100644 index 000000000..444326483 --- /dev/null +++ b/package/sash/src/shutdown.c @@ -0,0 +1,75 @@ +/* shutdown.c: + * + * Copyright (C) 1998 Kenneth Albanowski , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "sash.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#if __GNU_LIBRARY__ > 5 +#include +#endif + +int +main(argc, argv) + int argc; + char **argv; +{ + char *progname = argv[0]; + + if (argc > 2 && strcmp(argv[1], "-d") == 0) { + sleep(atoi(argv[2])); + argc -= 2; + } + if ((argc != 3) || (strcmp(argv[1], "-h") && strcmp(argv[1], "-r")) || strcmp(argv[2], "now")) { + printf("Usage: %s [-d delay] -h|-r now\n", progname); + exit(0); + } + + kill(1, SIGTSTP); + sync(); + signal(SIGTERM,SIG_IGN); + setpgrp(); + kill(-1, SIGTERM); + sleep(1); + kill(-1, SIGHUP); /* Force PPPD's down, too */ + sleep(1); + kill(-1, SIGKILL); + sync(); + sleep(1); + + if (strcmp(argv[1], "-h")==0) { +#if __GNU_LIBRARY__ > 5 + reboot(0xCDEF0123); +#else + reboot(0xfee1dead, 672274793, 0xCDEF0123); +#endif + } else { +#if __GNU_LIBRARY__ > 5 + reboot(0x01234567); +#else + reboot(0xfee1dead, 672274793, 0x01234567); +#endif + } + + exit(0); /* Shrug */ +} + -- cgit v1.2.3