home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3994 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.7 KB  |  51 lines

  1. Path: sparky!uunet!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!smurf.sub.org!news
  2. From: urlichs@smurf.sub.org (Matthias Urlichs)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: Fork ?
  5. Date: 28 Jul 1992 22:52:57 +0200
  6. Organization: University of Karlsruhe, FRG
  7. Lines: 39
  8. Message-ID: <154c39INNqrl@smurf.smurf.sub.org>
  9. References: <1992Jul6.010103.22037@news.uiowa.edu> <431@highett.mel.dbce.csiro.au>
  10. NNTP-Posting-Host: 127.0.0.1
  11.  
  12. In comp.unix.programmer, article <431@highett.mel.dbce.csiro.au>,
  13.   kang@mel.dbce.csiro.au (Kang Ho) writes:
  14. < In article <1992Jul6.010103.22037@news.uiowa.edu> gdcarson@icaen.uiowa.edu (Gregory Donald Carson) writes:
  15. < > I have a question about fork's.  I have a C program that I need to call
  16. < > repeatedly. [...deleted...]
  17. < > The C program that I need to call takes a long time to run, and I want it
  18. < > to run, while the main program continues. I have heard of a thing called 
  19. < > a fork, and was hoping someone could [...deleted...]
  20. < > The C program that I wish to call is passed an image data array, and 
  21. < > then displays it, its normal quit returns control to the calling program.
  22. < The program fragment is as follows: 
  23. < main()
  24. < {
  25. <   int pid;
  26. <   if ((pid=fork())<0){
  27. <     perror("fork unsuccessful");
  28. <     exit(-1);
  29. <     }
  30. <   else if (pid==0){
  31. <     /* child process */
  32. <     execl("/bin/imgdisp","imgdisp","param1",(char *)0);
  33. perror("imgdisp gone");
  34. exit(-1);
  35. <     }
  36. <   else {
  37. <     /* parent process */
  38. <     wait((int *)0);
  39. <     }
  40. <   ...
  41. < } 
  42.  
  43. -- 
  44. "I'd love to go out with you, but I did my own thing and now I've got
  45. to undo it."
  46. -- 
  47. Matthias Urlichs  --  urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de   /(o\
  48. Humboldtstrasse 7 -- 7500 Karlsruhe 1 -- Germany  --  +49-721-9612521     \o)/
  49.