Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <errno.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- int main()
- {
- FILE* fi;
- int time[15];
- char name[50][15];
- //----------------------------------------------
- fi = fopen("text.txt", "r");
- int i = 0;
- while(fscanf(fi, "%d %s\n", &time[i], name[i]) == 2)
- {
- i++;
- }
- fclose(fi);
- //--------------------------------------------------------------
- for (int k = 0; k < i; k++)
- {
- int pid;
- pid = fork();
- if(pid != 0)
- {
- sleep(time[k]);
- char path[100];
- strcat(path,"/home/alexey/");
- strcat( path, name[k]);
- execlp(path,name[k], NULL);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement