/* * mysplit.c - Another handy routine for testing your tiny shell * * usage: mysplit * Fork a child that spins for seconds in 1-second chunks. */ #include #include #include #include #include #include int main(int argc, char **argv) { int i, secs; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(0); } secs = atoi(argv[1]); if (fork() == 0) { /* child */ for (i=0; i < secs; i++) sleep(1); exit(0); } /* parent waits for child to terminate */ wait(NULL); exit(0); }