From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,d4695b171a94685b X-Google-Attributes: gidfee84,public X-Google-Thread: f7cee,d4695b171a94685b X-Google-Attributes: gidf7cee,public X-Google-Thread: 11035d,d4695b171a94685b X-Google-Attributes: gid11035d,public X-Google-Thread: 10c665,d4695b171a94685b X-Google-Attributes: gid10c665,public X-Google-ArrivalTime: 1994-05-27 09:55:19 PST Path: bga.com!news.sprintlink.net!hookup!news.kei.com!MathWorks.Com!noc.near.net!gradient.gradient.com!gradient!ddj From: ddj@gradient.gradient.com (Dave Johnson) Newsgroups: comp.unix.osf.osf1,comp.unix.solaris,comp.unix.sys5.r4,comp.bugs.sys5 Subject: Re: Fork bug in Sys5 (or similar) system Date: 27 May 1994 08:59:57 -0400 Organization: Gradient Technologies, Marlboro, MA Distribution: inet Message-ID: References: <2s0io0$248@overload.lbl.gov> <2s1kg2$7or@mail.fwi.uva.nl> <1994May26.181612.1484@cs.nott.ac.uk> <2s4c5i$ndt@mail.fwi.uva.nl> NNTP-Posting-Host: indy.gradient.com Xref: bga.com comp.unix.osf.osf1:1749 comp.unix.solaris:8118 comp.unix.sys5.r4:1885 comp.bugs.sys5:45 casper@fwi.uva.nl (Casper H.S. Dik) writes: >wja@cs.nott.ac.uk (William Armitage) writes: >>This seems to be a change introduced to support Multi-Threading. >>I hit this the other day while getting the Solaris 2 port of the Berkeley >>spooler going on my 2.3 machine. At startup the deamon forks a copy of >>itself for each printer to process any existing print jobs. >It's found in standard SysVr4 libc and doesn't appear to have anything >to do with MP support. It has one nice feature: > (head -2; head -2) < foo >now works as you'd (naively) expect. (It prints the first 4 lines, >not the first 2 lines + 2 lines at offset blocksize) >Casper In looking around the fork(2) manual pages on a couple SysV-ish systems, I found the note quoted earlier (always call fflush(3) on open file descriptors before doing fork) on some of them. Other systems (DG/UX and OSF/1) didn't mention the problem at all. Solaris 2.3 mentions the "other" problem with fork/exit, which is that you must call _exit(2) (instead of exit(3)) after a failed exec* call, but none of the others do. The exit man pages just say that _exit(2) will not perform the normal cleanup functions, without saying why you might want to avoid them. I don't remember where I learned not to do exit() in a child that hasn't exec'ed (maybe the BSTJ Nov '78 Unix paper?). This sort of lore should be clearly stated in the manual pages (under both fork AND exit in this case). Word-of-Net is nice, but you'd think after all these years it would be officially noted. Just waiting for the coffee to kick in.... Dave Johnson ddj@gradient.com