Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!veritas!geoff From: geoff@Veritas.COM (Geoffrey Leach) Newsgroups: comp.windows.x.motif Subject: Re: XtAddInput with pipes and fork and execlp Message-ID: <1991Jan24.141708.23987@Veritas.COM> Date: 24 Jan 91 14:17:08 GMT References: <36193@netnews.upenn.edu> Organization: VERITAS Software Lines: 33 From article <36193@netnews.upenn.edu>, by lau@desci.wharton.upenn.edu (Yan K. Lau): > I'm writing a user-interface front-end to several programs. These programs > asks a few questions and then prints output to the screen. The programs > that I call can be run separately. The interface is there to make it easier > to set the parameters. > > I've been following the Young book and have created pipes between my > interface program and a csh to which I send the commands to run these > programs. These programs are called one after another. Basically I > send the program name as stdin to the csh, anticipate the questions and > send the correct responses. > > I don't know exactly how it works but it does. The output is passed back > and displayed in a XmScrolledText with the stdin/stdout redirection and > a XtAddInput. > > My problem is that I don't know when a program that I call is finished. > For instance, I put up a WorkingDialog on the screen just before I call > a program. (An aside: If I don't ask the csh to sleep for a bit before > running the program, then the WorkingDialog doesn't get displayed > until after the program is done. How do I correct this?) I need to know > when to remove the WorkingDialog box when the program is done. How do I > do this? It's simple, tho bizzare. Instead of forking and execing your command, you fork and fork again. (This is not just forking around!) The child of the first fork waits for the child of the second (your command) to complete, then sends a message that the second child is to stdout, which is then procedded by your routine that is doing the AddInput. Have fun. Geoff Leach