home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / internal / 1793 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  1.3 KB

  1. Path: sparky!uunet!olivea!spool.mu.edu!uwm.edu!linac!highspl!burris
  2. From: burris@highspl (David Burris)
  3. Newsgroups: comp.unix.internals
  4. Subject: Re: How can a Unix process put itself in background?
  5. Message-ID: <1992Sep11.042010.4748@highspl>
  6. Date: 11 Sep 92 04:20:10 GMT
  7. References: <lma.716092591@dayton.Stanford.EDU>
  8. Organization: Dave's Home PC
  9. Lines: 35
  10.  
  11. From article <lma.716092591@dayton.Stanford.EDU>, by lma@dayton.Stanford.EDU (Larry Augustin):
  12. > lma@dayton.Stanford.EDU (Larry Augustin) writes:
  13. > The consensus seems to be that it can't be done (without forking), as
  14. > whatever shell exec'd the program will be stuck in a wait(), and could
  15. > only continue upon death of the child (or some interaction by the
  16. > user).  There would have to be some other convention for the running
  17. > program to tell the shell to continue.
  18. > Larry
  19.  
  20. Yes, you MUST fork another process.
  21.  
  22. Essentially, it looks like this:
  23.  
  24. pid = fork( );        /* fork the new process */
  25. if( pid != 0 )
  26. {
  27.     /* parent process */
  28.  
  29.     exit( 0 );
  30. }
  31. else
  32. {
  33.  
  34. /* Rest of program or exec() to new program */
  35.  
  36. If you want to inherit standard I/O it gets a little trickier, but
  37. hopefully you get the idea.
  38.  
  39. -- 
  40. ================================================================
  41. David Burris                    Aurora,Il.
  42. burris@highspl                   ..!linac!highspl!burris
  43. ================================================================
  44.