schlut@oski.toppoint.de (Olaf Schlueter) (04/22/91)
Included is a signal handler routine for init, which may be used to stop minix the safe way. I put it and a signal(SIGTERM, shutdown) into init. Now I can safely stop the system by typing kill 1 as root from any tty. -------------------------------------------------------------------- main() /* of init */ { void shutdown(); ... signal(SIGTERM, shutdown); /* before entering main loop */ ... } ... void shutdown() { int pid, status, fd; signal(SIGTERM, SIG_IGN); /* do not commit suicide */ kill(-1,SIGTERM); /* be gentle first */ kill(-1,SIGKILL); /* and brutal later */ while((pid = wait(&status)) > 0); sync(); fd = open(CONSOLE,1); write(fd, "\nIt is now safe to turn the system off.\n", 40); while(1); } ---------------------------------------------------------------- -- -- Olaf Schlueter, Sandkuhle 4-6, 2300 Kiel 1, Germany, Toppoint Mailbox e.V. schlut@oski.toppoint.de, olaf@tpki.toppoint.de, ...!unido!tpki!olaf