Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!teddy!panda!talcott!harvard!seismo!brl-tgr!ron From: ron@brl-tgr.ARPA (Ron Natalie) Newsgroups: net.lang.c Subject: Re: putting C programs in the background Message-ID: <7494@brl-tgr.ARPA> Date: Thu, 17-Jan-85 20:07:47 EST Article-I.D.: brl-tgr.7494 Posted: Thu Jan 17 20:07:47 1985 Date-Received: Sun, 20-Jan-85 05:10:59 EST References: <4600@cbscc.UUCP> <745@hou2h.UUCP> Organization: Ballistic Research Lab Lines: 28 > This is a continuation of the last article(Sorry). > > Can a program put another program into the background given its > pid. | > +-----> Not a supervisory or parent . > > Mark In the genereal case no. The problem that people here have a hard time coping with is that "BACKGROUND" is not a characturistic of a UNIX process. BACKGROUND happens when your shell decides not to wait for a process to finish. There is nothing you can do to the process itself to make this happen, what you have to do is do something to the parent to make it stop waiting. In 4.2 they handle this by putting special code in the shell. Sending a certain signal to a process causes it to enter a special "STOP" state and the parent gets an answer to it's wait call (similar to the way PTRACE operates). The parent can then CONTINUE the process without waiting for it to finish, i.e. putting it in the background. It can also CONTINUE it and wait, i.e. leave it in the forground. If you are clever in what you do with file descriptors and process groups you can even move background processes to the foreground. Detesting the CSH, I now have a 5R2 bourne shell running on 4.2 BSD that supports the above feature. -Ron