Component index
Section index

Component forktmp


Search

Type

Function

Summary

fork a subprocess and communicate with the parent

Description

A packaged solution to simplify forking a child process and retrieving results. This is done while being compatible with the GUI (other UI thread are still alive). This component is generally using along with the SHAREMEM template allowing the creation of shared memory area so the child and parent may exchange information.

void joining (int state, bool &end)
void message (bool &end)
void task ()
void timeout (bool &end, int duration)

Prototypes

int forktmp (int timeout, PRIVATE_MESSAGE &end)

Execute a sub-process and retrieve results. Return -1 if it failed to start the sub-process

int forktmp (int timeout)

Execute a sub-process and retrieve results. Return -1 if it failed to start the sub-process

int forktmp ()

Execute a sub-process and retrieve results. Return -1 if it failed to start the sub-process

Functags

void joining (int state, bool &end) Optional

Called when the child calls the join fhelper

This is executed in the parent process

void message (bool &end) Optional

Called when the PRIVATE_MESSAGE is received

forktmp optionally accepts a PRIVATE_MESSAGE argument. When a signal is sent to this message, the functag is called. The default behavior is to end the component.

void task () Mandatory

You place the code of the sub-process

void timeout (bool &end, int duration) Optional

Called when some timeout has ellapsed

The forktmp accept a timeout argument (in seconds). The functag is called whenever the timeout is reach. The functag must decide if the component must end. The default behavior is to end the component.

Fhelpers

void join (int state)

Send a message to the parent so the joining functag is executed

The join fhelper ends when the parent joining functag end. This is generally used to notify the parent of some event (a value is now available in shared memory for example).

void kill ()

Kill the sub-process