Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site lsuc.UUCP Path: utzoo!lsuc!dave From: dave@lsuc.UUCP (David Sherman) Newsgroups: net.lang.c Subject: Re: putting C programs in the background Message-ID: <329@lsuc.UUCP> Date: Thu, 24-Jan-85 16:35:57 EST Article-I.D.: lsuc.329 Posted: Thu Jan 24 16:35:57 1985 Date-Received: Thu, 24-Jan-85 17:21:58 EST References: <4600@cbscc.UUCP> <1269@bbncca.ARPA> Reply-To: dave@lsuc.UUCP (David Sherman) Organization: Law Society of Upper Canada, Toronto Lines: 34 Summary: stylistics: switch(fork()) || pid = fork(); || if( pid < 0 ) || { || /* Print error message */ || exit(1); || } || else if( pid > 0 ) || { || /* parent */ || exit(0); || } || /* else pid == 0, this is the child. Continue */ It's all stylistics, but my personal preference, particularly if the parent is going to wait around, is switch(fork()) { case -1; /* error message, maybe try again later */ break; case 0: /* child */ /* exec or whatever */ default: /* parent */ /* do things, then wait() */ } Of course, if done properly and not for some quick hack, that would be switch(pid=fork()), and so on. Dave Sherman -- {utzoo pesnta nrcaero utcs}!lsuc!dave {allegra decvax ihnp4 linus}!utcsrgv!lsuc!dave