From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c665,d4695b171a94685b X-Google-Attributes: gid10c665,public X-Google-Thread: fee84,d4695b171a94685b X-Google-Attributes: gidfee84,public X-Google-Thread: 11035d,d4695b171a94685b X-Google-Attributes: gid11035d,public X-Google-Thread: f7cee,d4695b171a94685b X-Google-Attributes: gidf7cee,public X-Google-ArrivalTime: 1994-05-27 20:27:44 PST Newsgroups: comp.unix.osf.osf1,comp.unix.solaris,comp.unix.sys5.r4,comp.bugs.sys5 Path: bga.com!news.sprintlink.net!hookup!swrinde!emory!gatech!psuvax1!hsdndev!admii!smokey!gwyn From: gwyn@arl.army.mil (Doug Gwyn (ACISD/MCSB) ) Subject: Re: Fork bug in Sys5 (or similar) system Message-ID: <1994May28.025115.19219@arl.army.mil> Organization: U.S. Army Research Laboratory APG, MD. References: <2s0io0$248@overload.lbl.gov> <2s4c5i$ndt@mail.fwi.uva.nl> <2s4t7i$6vl@mail.fwi.uva.nl> Distribution: inet Date: Sat, 28 May 1994 02:51:15 GMT Xref: bga.com comp.unix.osf.osf1:1768 comp.unix.solaris:8175 comp.unix.sys5.r4:1896 comp.bugs.sys5:47 In article <2s4t7i$6vl@mail.fwi.uva.nl> casper@fwi.uva.nl (Casper H.S. Dik) writes: >I'm not 100% sure, but a simple fflush((FILE*) 0) is probably sufficient >prior to fork(). Ooo, finally somebody found a use for the feature I lobbied for in X3J11! Actually, exit() is seldom appropriate in this context; it not only does stdio "cleanup", it also executes the atexit-registered functions, some of which the programmer may not even realize were registered (by one of the support libraries his application was linked with, for example). The real heart of the matter (as I indicated in a previous post) is that there is a fundamental difference between information that the "kernel" coordinates and information private to the process. In the good old days we used to document the former in Section 2 of the UNIX Programmer's Manual and the latter in Section 3. POSIX.1 tried to blur the distinction but had to reintroduce it in the guise of "underlying functions". Since fork() is a kernel action (aka "system call") the other operations related to using it had better be left to the kernel to handle, i.e. _exit() not exit(), or read() not fread(). I found the description of SVR4's attempt to unread a buffer rather amusing, since obviously some UNIX file types simply cannot be unread. For some reason this reminds me of the earlier UNIX System V stdio attempts to make use of printf() etc. work reliably when invoked from a signal handler. In both cases, the job simply cannot be done right. (With the ability to "hold" signals within a critical section, it is now at least possible to get the latter right, and everyone implementing "thread-safe" stdio has had to figure out how.)