Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!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: Re: (PC/AT) why not include 'sync' in keyboard.c (for rebooting?) Message-ID: <33@oski.toppoint.de> Date: 21 Apr 91 18:16:14 GMT References: <3044@krafla.rhi.hi.is> <1991Apr16.111539.1287@syd.dit.CSIRO.AU> <792@philica.ica.philips.nl> Lines: 39 adrie@philica.ica.philips.nl (Adrie Koolen) writes: [about a safe way of shutting a minix system down by use of a daemon process] I think the best place for this daemon is init. On the ST Version I can stop every running process by hitting Ctrl-Alt-F10. A kill(-1,9) call is shot this way. This will kill all user processes, even the shell or program I am currently in. cron, etc/update, my nnmaster and tostp server are all gone then. The only process which survives the kill(-1,9) is init. It does not receive the signal, as it belongs to the OS itself like FS or MM. The problem is that all what init is watching after kill(-1,9) are login processes terminating. As conditioned it reponses by restarting them. Also, betwen performing the sync and hitting cltrl-alt-F10 someone could issue a write operation. So there has to be a way to tell even init that the system is about to die and to put the things into proper order (first kill, then sync). My suggestion is to implement a keystroke which send a kill(1,SIGTERM) (SIGTERM to init). Init should then perform kill(-1,9) stops all user processes. sync() flushes the cache. and should go idle waiting for the user to turn the system off (by flipping the power switch or pressing ctrl-alt-del). If you are running minix as an environment for more serious things then personal education (no flames please :-)) and do not want to place bodyguards to your console, you can even remove all this PC like finger breaking keyboard stuff and write a shutdown command: main() { kill(1,15); } executable for root only, of course.