Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/wait.h>
  6.  
  7. int main(int argc, char ** argv) {
  8.  
  9.     // int i = 0;
  10.     // pid_t parent_pid;
  11.     // pid_t child_pid;
  12.  
  13.     int procNum = atoi(argv[1]);
  14.  
  15.     if(argc == 1) {     //ew. argc < 2
  16.         printf("Please insert at least one option.\n");
  17.         return 0;
  18.     }
  19.  
  20.     char * i_procNum;   //system wiedenski, jak odsiecz; czastki zmiennych
  21.     char * pc_procNum;  //pointer char
  22.     asprintf(&pc_procNum, "%d", (procNum - 1));
  23.  
  24.     //cos tu powinno byc, ale kurwa nie wim co
  25.  
  26.     for(int i = 0; i < procNum; i++) {
  27.         pid_t child_pid = fork();
  28.        
  29.         if(child_pid == 0) {
  30.             char * c_temp[32];
  31.  
  32.             if(argv[2] == NULL) {
  33.                 printf ("Numer PID procesu macierzystego wynosi %d\n", (int) getppid());
  34.             }
  35.             else {
  36.             }
  37.         }
  38.     }
  39.  
  40.     for(int i = 0; i < procNum; i++) {
  41.         wait(0);        //jak zorbic dobrego wait'a
  42.     }
  43.  
  44.     //i co teraz??
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement