Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!adm!baccala@USNA.MIL From: baccala@USNA.MIL (Brent W Baccala) Newsgroups: comp.unix.questions Subject: Re: A couple questions Message-ID: <6939@brl-adm.ARPA> Date: Fri, 17-Apr-87 00:21:54 EST Article-I.D.: brl-adm.6939 Posted: Fri Apr 17 00:21:54 1987 Date-Received: Sun, 19-Apr-87 10:11:20 EST Sender: news@brl-adm.ARPA Lines: 33 "Frederick M. Avolio" writes: >...(If on a 4.*BSD ort Ultrix system use >cfork instead... Why? I don't know, the same reason you type 'sync' >three times before halting :-).) I've never heard of cfork, and it can't find a manual page for it on our 4.3 BRL system. I don't know much (anything) about Ultrix, but do you mean vfork? vfork does a "virtual" fork - most of the parent's memory space is not copied. Instead, the parent is suspended while the child uses some of its memory. If you're going to do an exec of some flavor, you don't to change the parent's memory anyway, so this is very memory-efficient. There are (of course) strings attached to what you can and can't do in a vfork - read the man page. In particular, you can't return from the function that called vfork because that would screw up the stack frame. You also can't use exit on an error (use _exit) because exit will close stdio structures in the parent. Its even wrong (as some people have suggested) to use exit from a fork, because even though you have a separate set of file descriptors, data buffered before the fork will get flushed twice. P.S. "_exit" is a fast exit - it terminates the process without doing any of the housekeeping that "exit" does (by calling "_cleanup"). - BRENT W. BACCALA - Computer Aided Design/Interactive Graphics U.S. Naval Academy Annapolis, MD