home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / 15786 < prev    next >
Encoding:
Text File  |  1992-08-29  |  2.8 KB  |  78 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!stanford.edu!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse
  3. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  4. Subject: Re: XView forking problem
  5. Message-ID: <1992Aug28.092908.8725@thunder.mcrcim.mcgill.edu>
  6. Keywords: XView forking problem, how ?
  7. Organization: McGill Research Centre for Intelligent Machines
  8. References: <1992Aug27.121825.24459@imada.ou.dk>
  9. Date: Fri, 28 Aug 92 09:29:08 GMT
  10. Lines: 67
  11.  
  12. In article <1992Aug27.121825.24459@imada.ou.dk>, adelt@imada.ou.dk (Adel Shavandi) writes:
  13.  
  14. > I have a problem when forking my XView program:
  15.  
  16. > switch (pid=fork()) 
  17. >     {
  18. >     case -1:
  19. >         //perror("VisInterface::action(): fork() failed!");
  20. >         exit (1);
  21. >     case 0:    // child
  22. >         childProcess ();
  23. >     default:
  24. >         parentProcess ();
  25. >         break;
  26. >     }
  27.  
  28. > In the child process I try to draw in a window and display* that is
  29. > shared with the parent.
  30.  
  31. This is guaranteed disaster.  Here's something I posted some time back
  32. that attempted to give some idea why:
  33.  
  34. Newsgroups: comp.windows.x
  35. Path: thunder.mcrcim.mcgill.edu!mouse
  36. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  37. Subject: Re: fork() and Xlib
  38. Message-ID: <1992Mar1.092825.19741@thunder.mcrcim.mcgill.edu>
  39. Organization: McGill Research Centre for Intelligent Machines
  40. References: <1992Feb25.100948.10891@fwi.uva.nl>
  41. Date: Sun, 1 Mar 92 09:28:25 GMT
  42. Lines: 35
  43.  
  44. In article <1992Feb25.100948.10891@fwi.uva.nl>, stolk@fwi.uva.nl writes:
  45.  
  46. > I'm experiencing a really nasty bug in my X11 application.  The
  47. > trouble is that it just hangs... no error mesgs.  I suspect the
  48. > source of the trouble to be fork().
  49.  
  50. > My X11 applications forks, and both processes continue using the
  51. > Xserver with the same window and display.
  52. > Is this dangerous?
  53.  
  54. Yes, very.  This will not work.  Making it work is so close to
  55. impossible that I wouldn't even try.
  56.  
  57. > I can imagine that the 1st process sends some command to the server,
  58. > and when the command is halfway through, the 2nd process takes over
  59. > the CPU control, and sends a command as well.
  60.  
  61. Yes, that's one of the dangers.  Another is that something similar can
  62. happen to stuff flowing in the other direction (replies, events, and
  63. errors): something that has to go to one process (a reply to a request,
  64. say) can end up getting read by the other.  There are worse problems,
  65. too; for example, sequence numbers will be mangled.  The server's idea
  66. of the current sequence number will differ from that of either Xlib,
  67. since each Xlib keeps its own count, which count independently starting
  68. at the time of the fork(), while the server counts requests in the
  69. merged stream.  Thus, replies will, from the point of view of the
  70. receiving Xlib, have the wrong sequence number.  This is probably where
  71. your hang is coming from: Xlib is waiting for a sequence number it will
  72. never see.
  73.  
  74.                     der Mouse
  75.  
  76.             old: mcgill-vision!mouse
  77.             new: mouse@larry.mcrcim.mcgill.edu
  78.