Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <errno.h>
- #include <string.h>
- #include <unistd.h>
- #include <time.h>
- #include <signal.h>
- #include <sys/signal.h>
- void ProcessWork(pid_t PID, int time) {
- printf("%d\n", time);
- }
- int main(int argc, char* argv[]){
- pid_t pid = 0;
- int PID = getpid();
- int n = 10;
- int times[n];
- pid_t all_pid[n];
- for (int i = 0; i < n; i++) {
- times[i] = i + 1;
- }
- for (int i = 0; i < n; i++) {
- pid = fork();
- if (pid == 0) {
- break;
- } else {
- ProcessWork(pid, times[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement