/* * * CreateProcess - Forks off a process, and runs the passed function * with the passed integer parameter. * * Modified from prodcons.c by Theo Van Dinter, 96/09/09 * * */ #include "mailbox.h" /* * CreateProcess - 96/09/09 * * CreateProcess will now take two parameters, and pass the second to the * forked child. * */ int CreateProcess(int (*pFunc)(),int dvalue) { int pid; if ((pid = fork()) == 0) /* We're the child */ { (*pFunc)(dvalue); /* Call function with value */ exit(0); /* If function doesn't quit, we'll die implicitly */ } return(pid); /* Return fork() value to the parent (-1 for error, PID otherwise) */ } /* * InitMailbox - 96/09/09 * * By: Theo Van Dinter (felicity@kluge.net) * * Initializes semaphores and shared memory "mailboxes". * * No calling parameters * Returns a -1 on error, 0 if ok. * */ int InitMailbox() { int loop; for(loop=0;loopiFrom=0; inbox[loop]->wType=0; inbox[loop]->wVal1=0; inbox[loop]->wVal2=0; inbox[loop]->wTotal=0; } return(0); } /* * CleanMailbox - 96/09/09 * * By: Theo Van Dinter (felicity@kluge.net) * * Cleans up all semaphores and shared memory allocations. * * No calling parameters * Returns a -1 on error, 0 if ok. * */ int CleanupMailbox() { int loop; for(loop=0;loop