zemon@felix.UUCP (Art Zemon) (06/29/87)
Andy Tanenbaum posted source code for cal(1) a few weeks ago, adding that the posted program did not work. The only thing required to make it work is to add the line _cleanup(); before every call to exit(). -- -- Art Zemon FileNet Corporation Costa Mesa, California ...!hplabs!felix!zemon
gnu@hoptoad.uucp (John Gilmore) (07/02/87)
zemon@felix.UUCP (Art Zemon) wrote: > Andy Tanenbaum posted source code for cal(1) a few weeks > ago, adding that the posted program did not work. The only > thing required to make it work is to add the line > _cleanup(); > before every call to exit(). Wouldn't it be easier to replace the supplied exit() with one that worked, e.g. that implemented onexit(), so stdio could get its buffers flushed without rewriting every program? -- {dasys1,ncoast,well,sun,ihnp4}!hoptoad!gnu gnu@ingres.berkeley.edu Alt.all: the alternative radio of the Usenet. Contributions welcome - post 'em
zemon@felix.UUCP (Art Zemon) (07/02/87)
In article <2352@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) writes: > >Wouldn't it be easier to replace the supplied exit() with one >that worked, e.g. that implemented onexit(), so stdio could get >its buffers flushed without rewriting every program? The original idea behind this was to keep the tools in /usr/bin and /bin small by not including the stdio library. Exit(), if it called _cleanup(), would bring in large chunks of otherwise unused code. I think a better solution would be to rename the existing exit() to _exit() and create an exit() subroutine which calls _cleanup() and change the tools which don't use stdio to call _exit(). Whew! I said all that in one breath. :-) -- -- Art Zemon FileNet Corporation Costa Mesa, California ...!hplabs!felix!zemon
stuart@bms-at.UUCP (Stuart D. Gathman) (07/05/87)
In article <3169@felix.UUCP>, zemon@felix.UUCP (Art Zemon) writes: > I think a better solution would be to rename the existing > exit() to _exit() and create an exit() subroutine which > calls _cleanup() and change the tools which don't use stdio > to call _exit(). Whew! I said all that in one breath. :-) An even better solution is to have exit(1) invoke an (initially empty) chain of pointers to cleanup functions. Have _flushin (or whatever) install _cleanup() when invoked the first time. Modifying fopen(3) doesn't work for stdin & stdout! -- Stuart D. Gathman <stuart@bms-at.uucp> <..!seismo!dgis!bms-at!stuart>
mpl@sfsup.UUCP (07/06/87)
In article <3169@felix.UUCP>, zemon@felix.UUCP writes: > In article <2352@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) writes: > >Wouldn't it be easier to replace the supplied exit() with one [text deleted] > I think a better solution would be to rename the existing > exit() to _exit() and create an exit() subroutine which > calls _cleanup() and change the tools which don't use stdio > to call _exit(). Whew! I said all that in one breath. :-) That's a good solution, but it also "breaks" some code. How about, in the code which initializes iob (or whatever it's called in MINIX), put the line extern int (*__cleanup)(); extern int _cleanup(); __cleanup = _cleanup; and change exit() to say: int (*__cleanup)(); exit(n) int n; { if (__cleanup) (*__cleanup)(); _exit(n); } This way, if stdio routines are NOT loaded, __cleanup is not set, so there is NO REFERENCE TO _CLEANUP (it won't be loaded ro executed). If stdio IS loaded, __cleanup is set to _cleanup (causing _cleanup to be loaded) and it get's executed before _exit gets called (which does whatever the current exit() does). This maintains FULL code compatibility with REAL UNIX(R). UNIX is a registered trademark of AT&T Well? Any comments? I'd be happy to implement this, if I can ever get my $&^@%&@# hard disk working! Mike Lindner