#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char ** argv) {
int i;
if (argc < 3) {
printf("Usage: %s seconds command arg0 ...\n", argv[0]);
exit(EXIT_FAILURE);
}
//sscanf(argv[1], "%d", i);
i = atoi(argv[1]);
while (1) {
pid_t p = fork();
switch (p) {
case -1:
perror("fork");
exit(EXIT_FAILURE);
case 0:
/*child*/
execvp(argv[2], &argv[2])
perror("exec");
exit(EXIT_FAILURE);
default:
/*parrent*/
sleep(i);
}
}
return 0;
}