#include "stdinc.h" // // Purpose: Problem 6, HW 3 // Usage: forkit // int main (int argc, char *argv[]) { pid_t pid; int status; struct timeval tv_child, tv_parent; int x = 3; if ( (pid = Fork()) == 0) { // child gettimeofday(&tv_child, 0); sleep(2); printf ("child %d:\t x = %d, tv_child = (%ld, %ld)\n", getpid(), x, tv_child.tv_sec, tv_child.tv_usec); exit(0); } gettimeofday(&tv_parent, 0); x = x + 1; Waitpid(pid, &status,0); printf ("parent %d:\t x = %d, tv_parent = (%ld, %ld)\n", getpid(), x, tv_parent.tv_sec, tv_parent.tv_usec); return 0; }