fork

main(argc,argv)
int argc;
char *argv[];
{
    char ch, first, last;
    int pid;
    long i;

    if((pid = fork())>0) { /* parent */
        first = 'A';
        last = 'Z';
    }
    else if(pid == 0) { /* child */
        first = 'a';
        last = 'z';
    }
    else { /* not fork(2) */
        perror(argv[0]);
        exit(1);
    }
    printf("\n");
    for(ch = first; ch <= last; ch++) {
        /* delay loop */
        for(i=0; i<= 100000; i++);
        write(1, &ch, 1);
    }
}

Comments