From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11035d,d4695b171a94685b X-Google-Attributes: gid11035d,public X-Google-Thread: fee84,d4695b171a94685b X-Google-Attributes: gidfee84,public X-Google-Thread: 10c665,d4695b171a94685b X-Google-Attributes: gid10c665,public X-Google-Thread: f7cee,d4695b171a94685b X-Google-Attributes: gidf7cee,public X-Google-ArrivalTime: 1994-05-30 20:23:03 PST Xref: gmd.de comp.unix.osf.osf1:3462 comp.unix.solaris:18825 comp.unix.sys5.r4:8355 comp.bugs.sys5:220 Newsgroups: comp.unix.osf.osf1,comp.unix.solaris,comp.unix.sys5.r4,comp.bugs.sys5 Path: gmd.de!nntp.gmd.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!swrinde!news.uh.edu!uuneo.neosoft.com!nmtigw!peter From: peter@nmti.com (Peter da Silva) Subject: Re: Fork bug in Sys5 (or similar) system Message-ID: Sender: peter@nmti.com (peter da silva) Organization: Network/development platform support, NMTI References: <2s0io0$248@overload.lbl.gov> <2s1kg2$7or@mail.fwi.uva.nl> <1994May26.181612.1484@cs.nott.ac.uk> Date: Tue, 31 May 1994 01:25:36 GMT Enter old-fogey mode. In article <1994May26.181612.1484@cs.nott.ac.uk>, William Armitage wrote: > casper@fwi.uva.nl (Casper H.S. Dik) writes: > > You're not allowed to call exit(3) after fork(), unless you > > flush all files before calling fork(). > This seems to be a change introduced to support Multi-Threading. No, it has *always* been true that you can't call any routine that might execute fflush() after a fork() unless you know that all buffered output streams were already fflush()ed before the fork(). This includes: printf, scanf, fread, fwrite, getc, getchar, fgetc, fgets, fprintf, fscanf, gets, puts, fputs, putc, fputc, exit, fclose, pclose, ... I was aware of this in 1979, when the standard I/O library was itself pretty new (in fact, you pulled it in explicitly with -lS), so it shouldn't be a surprise any more. > lpd ran away forking printer processes. Trussing things showed that the > fclose was doing an lseek before closing. Putting an fflush before the > fork solved the problem. That's just a new *symptom* of an existing problem. Normally it's only output file descriptors that trigger the bug. I'm kinda surprised the routine didn't call close (normally you only call open, close, pipe, dup, and other O/S-level routines between a fork and exit/exec). -- Peter da Silva `-_-' Network Management Technology Incorporated 'U` 1601 Industrial Blvd. Sugar Land, TX 77478 USA +1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"