home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!uwm.edu!linac!highspl!burris
- From: burris@highspl (David Burris)
- Newsgroups: comp.unix.internals
- Subject: Re: How can a Unix process put itself in background?
- Message-ID: <1992Sep11.042010.4748@highspl>
- Date: 11 Sep 92 04:20:10 GMT
- References: <lma.716092591@dayton.Stanford.EDU>
- Organization: Dave's Home PC
- Lines: 35
-
- From article <lma.716092591@dayton.Stanford.EDU>, by lma@dayton.Stanford.EDU (Larry Augustin):
- > lma@dayton.Stanford.EDU (Larry Augustin) writes:
- >
- > The consensus seems to be that it can't be done (without forking), as
- > whatever shell exec'd the program will be stuck in a wait(), and could
- > only continue upon death of the child (or some interaction by the
- > user). There would have to be some other convention for the running
- > program to tell the shell to continue.
- >
- > Larry
-
- Yes, you MUST fork another process.
-
- Essentially, it looks like this:
-
- pid = fork( ); /* fork the new process */
- if( pid != 0 )
- {
- /* parent process */
-
- exit( 0 );
- }
- else
- {
-
- /* Rest of program or exec() to new program */
-
- If you want to inherit standard I/O it gets a little trickier, but
- hopefully you get the idea.
-
- --
- ================================================================
- David Burris Aurora,Il.
- burris@highspl ..!linac!highspl!burris
- ================================================================
-