编辑代码

#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/types.h>

int main (int argc, char *argv[]) {
    int rc = fork();
    if (rc < 0) {
        fprintf(stderr, "fork failed\n");
    } else if (rc == 0) {   
        printf("childFork: x=%d\n",x);
    } else {
        int wc = wait(NULL);
        printf("parentFork: x=%d\n",x);
    }
    return 0;
}