Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!seismo!uunet!mcsun!hp4nl!charon!guido From: guido@cwi.nl (Guido van Rossum) Newsgroups: comp.std.c Subject: Re: Question: signal and program termination Keywords: signal, exit, termination Message-ID: <2879@charon.cwi.nl> Date: 31 Jan 91 14:49:06 GMT References: <87792@tut.cis.ohio-state.edu> <147@thor.UUCP> Sender: news@cwi.nl Lines: 25 scjones@thor.UUCP (Larry Jones) writes: >The difference is that exit() exits from the program without the >interrupted operation ever being resumed. Although it is possible >that the exit handlers could fail because an interrupted operation >left some global data in a fatally inconsistent state, careful >coding should be able to prevent fatally inconsistent states. A >quality implementation should code all the library routines this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >way. ^^^^ I doubt it. Both the C standard and POSIX explicitly forbid the use in signal handlers of printf(), malloc() and related things for exactly this reason: if you get an asynchronous signal while one of these is manipulating its global state, you may be in trouble if you try to use that global state from the handler. Relying on "quality implementations" only passes the problem on to the poor guy who has to port your code to a platform with only a lesser-quality implementation available. BTW, most of today's stdio and malloc implementations are lesser-quality, according tou your standards... -- Guido van Rossum, CWI, Amsterdam "It's a bit runny, sir"