home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!stanford.edu!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Subject: Re: XView forking problem
- Message-ID: <1992Aug28.092908.8725@thunder.mcrcim.mcgill.edu>
- Keywords: XView forking problem, how ?
- Organization: McGill Research Centre for Intelligent Machines
- References: <1992Aug27.121825.24459@imada.ou.dk>
- Date: Fri, 28 Aug 92 09:29:08 GMT
- Lines: 67
-
- In article <1992Aug27.121825.24459@imada.ou.dk>, adelt@imada.ou.dk (Adel Shavandi) writes:
-
- > I have a problem when forking my XView program:
-
- > switch (pid=fork())
- > {
- > case -1:
- > //perror("VisInterface::action(): fork() failed!");
- > exit (1);
- > case 0: // child
- > childProcess ();
- > default:
- > parentProcess ();
- > break;
- > }
-
- > In the child process I try to draw in a window and display* that is
- > shared with the parent.
-
- This is guaranteed disaster. Here's something I posted some time back
- that attempted to give some idea why:
-
- Newsgroups: comp.windows.x
- Path: thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Subject: Re: fork() and Xlib
- Message-ID: <1992Mar1.092825.19741@thunder.mcrcim.mcgill.edu>
- Organization: McGill Research Centre for Intelligent Machines
- References: <1992Feb25.100948.10891@fwi.uva.nl>
- Date: Sun, 1 Mar 92 09:28:25 GMT
- Lines: 35
-
- In article <1992Feb25.100948.10891@fwi.uva.nl>, stolk@fwi.uva.nl writes:
-
- > I'm experiencing a really nasty bug in my X11 application. The
- > trouble is that it just hangs... no error mesgs. I suspect the
- > source of the trouble to be fork().
-
- > My X11 applications forks, and both processes continue using the
- > Xserver with the same window and display.
- > Is this dangerous?
-
- Yes, very. This will not work. Making it work is so close to
- impossible that I wouldn't even try.
-
- > I can imagine that the 1st process sends some command to the server,
- > and when the command is halfway through, the 2nd process takes over
- > the CPU control, and sends a command as well.
-
- Yes, that's one of the dangers. Another is that something similar can
- happen to stuff flowing in the other direction (replies, events, and
- errors): something that has to go to one process (a reply to a request,
- say) can end up getting read by the other. There are worse problems,
- too; for example, sequence numbers will be mangled. The server's idea
- of the current sequence number will differ from that of either Xlib,
- since each Xlib keeps its own count, which count independently starting
- at the time of the fork(), while the server counts requests in the
- merged stream. Thus, replies will, from the point of view of the
- receiving Xlib, have the wrong sequence number. This is probably where
- your hang is coming from: Xlib is waiting for a sequence number it will
- never see.
-
- der Mouse
-
- old: mcgill-vision!mouse
- new: mouse@larry.mcrcim.mcgill.edu
-