Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!cs.umn.edu!msi.umn.edu!math.fu-berlin.de!fauern!unido!mcshh!abqhh!tpki!oski!schlut From: schlut@oski.toppoint.de (Olaf Schlueter) Newsgroups: comp.os.minix Subject: System shutdown using init Message-ID: <34@oski.toppoint.de> Date: 21 Apr 91 18:16:18 GMT Lines: 38 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