/* count.c * output consecutive integers, waiting between each. * $ ./count * $ ./count 3 */ #include #include #include #define SECONDS 100 int main(int argc, char* argv[]){ int i=0, delay=1, elapsed=0; pid_t pid = getpid(); if (argc == 2) sscanf(argv[1], "%d", &delay); while (i < SECONDS){ i++; printf(" i=%d at %d sec in process %d \n", i, elapsed, pid); sleep(delay); elapsed += delay; } return 0; }