Anyone know how I can run this as a separate process from the parent program, like a child process,

and return the result back to the parent program.

this script is as follows.

if file "/Stuff/s" exists then continue to run, if file "/Stuff/t" exists, then print "started" if file "/Stuff/t" does not exists, then print "stopped"

if file "/Stuff/s" does not exist then print "quit" and then quit.


Code:
void controlxmmscheck( ) {

if( access( "/Stuff/s", F_OK ) != -1 ) {

xmmscheck

} else {

gtk_label_set_text(GTK_LABEL (label_status), gettext("quit"));

}

void controldiversion( ) {

if( access( "/Stuff/s", F_OK ) != -1 ) {

diversion

} else {

gtk_label_set_text(GTK_LABEL (label_status), gettext("quit"));

}

void xmmscheck( ) {


/* Check if /stream1/t exists */
if( access( "/Stuff/t", F_OK ) != -1 ) {

/* Then status is "started" */

gtk_label_set_text(GTK_LABEL (label_status), gettext("started"));

/* Switch to diversion function */
controldiversion

/* Or else wait for 5 seconds */
} else {
sleep(5);

/* Start this File all over again */
controlxmmscheck

}


void diversion( ) {

/* check if file /stream1/t exists */
if( access( "/Stuff/t", F_OK ) != -1 ) {

*/ Then wait for 5 Seconds */
sleep(5);

/* Start this function again */
controldiversion

} else {


/* then status is stopped */
gtk_label_set_text(GTK_LABEL (label_status), gettext("stopped"));

/* Switch to xmmscheck function */
controlxmmscheck


}