Path: utzoo!attcan!uunet!ginosko!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hplabsz!mayer From: mayer@hplabsz.HPL.HP.COM (Niels Mayer) Newsgroups: comp.windows.x Subject: Re: Parallel processes to X ? Message-ID: <3839@hplabsz.HPL.HP.COM> Date: 23 Aug 89 08:00:39 GMT References: <140@elctr.UUCP> Reply-To: mayer@hplabs.hp.com (Niels Mayer) Organization: Hewlett-Packard Labs, Software Technology Lab, Palo Alto, CA. Lines: 48 Summary: Expires: Sender: Followup-To: In article <140@elctr.UUCP> hbr@elctr.UUCP (Hans B| Randgaard) writes: >Are there some way to invoke background processes still using X to >control everything, but without getting a copy of the widgets ? Xt programming is event-driven programming, so why not make your background process send it's results back to your application by running it in a subshell (see popen()) and having any output from the pipe get processed as an "event" via XtAddInput(). If you don't like it running in a subshell, make a server/client interface. Take a look at xwebster 1.0 (from x11r3 contrib tape) for an example of this approach. >However the analysis is invoked by pushing a command-button and it >can take quite some time (several minutes) before the analysis is >through. >What I want to do is to make the analysis run as a parallel process >so that the user can make other things(maybe kill the analysis >clicking another button) during the analysis. You can certainly do that with the above approach. Alternately, you can turn things upside down and do event processing once per n iterations of your analysis loop: do { sprintf(temptext, "Trying webster server at address %s ...\n", host_addr); Display_Def_Text_Append(temptext); Display_Def_Refresh(); XSync(display, FALSE); while (XtPending()) { /* since we can't get back to XtMainLoop yet-*/ XEvent event; /*-we process the events here... (yech) */ XtNextEvent(&event); XtDispatchEvent(&event); } /* iteration of time consuming operation */ ... } while (blablabla)... The above comes from xwebster 1.1 (on expo.lcs.mit.edu's contrib ftp dir) and I don't know what that XSync() is doing there... If I remember, nested event loops require r3 Xt. >I have made several >fork experiments, but I always(of course) get a copy of the whole >widget tree, which I certainly don't need or want. Scary! -- Niels "don't ask me about webster servers" Mayer.