Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6. #include <wait.h>
  7. int main(int argc, char *argv[])
  8. {
  9.     pid_t p=0;
  10.     struct data
  11.     {
  12.         int t;
  13.         char c[100];
  14.     }sv;
  15.     FILE *f=fopen(argv[1],"r");
  16.     if(f==NULL)
  17.     {
  18.         printf("Impossible open source of data\n");
  19.         exit(1);
  20.     }
  21.     while(fscanf(f,"%d%s",&sv.t,sv.c)!=EOF)
  22.     {
  23.         p=fork();
  24.         if(p==0)
  25.         {
  26.             sleep(sv.t);
  27.             execv(sv.c,NULL);
  28.         }
  29.     }
  30.     waitpid(p,NULL,0);
  31.     fclose(f);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement