Re: XForms: forking a child

Robert S. Mallozzi (mallors@crazyhorse.msfc.nasa.gov)
Fri, 29 May 1998 09:12:26 -0500 (CDT)

# To subscribers of the xforms list from "Robert S. Mallozzi" <mallors@crazyhorse.msfc.nasa.gov> :

On 28 May, Tristan Savatier wrote:
> # To subscribers of the xforms list from Tristan Savatier <tristan@bok.net> :
>
> AMIT BHATNAGAR wrote:
>>
>> # To subscribers of the xforms list from AMIT BHATNAGAR <amit@cs.dal.ca> :
>>
>> On Thu, 28 May 1998, Tristan Savatier wrote:
>>
>> > # To subscribers of the xforms list from Tristan Savatier <tristan@bok.net> :
>> >
>> > Another similar example is the MpegTV Player (mtv/mtvp).
>>
>> > The front-end (mtv) implements the GUI with Xforms.
>> > The actual work of playing the MPEG stream is done by
>>
>> I have the source... but I can't seem to find where you actually fork()
>> and exec mtvp. I have looked in mtv.c.... I figured thats where you would
>> make the calls..
>>
>> or am I a dummy and just can't see? ;)
>
> The fork is done in the call g2a_init().
>
> The code of g2a_init() is provided only in object format,
> but it contains something like:
>
> int
> g2a_init(
> [...]
> )
> {
> pid_t player_pid; /* pid of player process */
>
> /* first, open the communication pipes */
> [...]
>
> /* second, fork a child process */
> player_pid = fork();
>
> if (player_pid == -1) {
> return -1;
> }
>
> if (player_pid == 0) { /* this is the child (forked) process */
>
> /*
> * here the child process does an execvp() of mtvp
> * with the right options. this will becomes the mtvp process...
> */
> [...]
>
> /* of course, the end of this block is never reached because
> of the execvp() */
>
> }
>
> /* this is the mtv process... */
> return 0;
> }
>

A similar piece of code appears in the xfpovray sources
(callbacks.c). xfpovray does not currently pass data via
pipes between itself and POV-Ray (it's on my todo list :-).
It forks() the POV-Ray child process, then monitors that
process with waitpid() so that it knows when the child
process has terminated.

-bob mallozzi

-- 
Robert S. Mallozzi
http://cspar.uah.edu/~mallozzir/

_________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuf2.usuhs.mil or see http://bob.usuf2.usuhs.mil/mailserv/xforms.html XForms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/