Hi all,

whats the best method of sharing a variable between a child and a parent?

specifically I want the parent to exit successfully only if the child has initialised properly, otherwise exit with an error as well as the child.

TIA, rotis23

Code:
//share this memory between parent and child
int confirm_ok = -1;

switch (pid = fork())
{
    case 0:
        //do some initilisation stuff
        confirm_ok = 0;
        daemon_loop();
        break;
    default;
        while(confirm_ok == -1)
        {
              sleep(1);
        }
        if(confirm_ok == 1) 
            exit(EXIT_FAILURE);
        else
            exit(EXIT_SUCCESS);
}