[comp.windows.x] Parallel processes to X ?

hbr@elctr.UUCP (Hans B| Randgaard) (08/22/89)

Hello folks.

I have made some X userinterface, using the X-toolkit(X11R2) for
a program which makes some analysis(unimportant here) on some files.
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. 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.

My question is:

Are there some way to invoke background processes still using X to
control everything, but without getting a copy of the widgets ?
-- 
------ Hans Boe Randgaard - ElektronikCentralen - Denmark ------
E-mail:  hbr@elctr.dk, Phone: +45 42 86 77 22, Fax: +45 42 86 58 98
Address: Venlighedsvej 4                        ** |_| |) |) **
         2970 Hoersholm - DENMARK               ** | | |) |\ **

klee@gilroy.pa.dec.com (Ken Lee) (08/23/89)

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 ?

Take a look at programs like xmh (in the MIT X distribution).  It uses
widgets for the user interface, but non-X programs for the "real
work".  The widget callback functions just fork/exec the non-X
programs.  This is, of course, very operating system dependent.

Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@decwrl.dec.com
uucp: uunet!decwrl!klee

mayer@hplabsz.HPL.HP.COM (Niels Mayer) (08/23/89)

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.

de@comp.lancs.ac.uk (David England) (08/23/89)

In article <1719@bacchus.dec.com> klee@gilroy.pa.dec.com (Ken Lee) writes:
>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 ?
>
>Take a look at programs like xmh (in the MIT X distribution).  It uses
>widgets for the user interface, but non-X programs for the "real
>work".  

Has anyone sucessfully done this on a Sequent using m_fork ?
I've tried, but any X program I link -lpps to falls over.

-- 
uucp:   ...!mcvax!ukc!dcl-cs!de or: ...!uunet!comp.lancs.ac.uk!de
arpa/janet: de@comp.lancs.ac.uk +44 524 65201 ex 3784
"The Bluebird of happiness long absent from his life,
Ned is visited by the chicken of depression"