Advertisement
IvoB1n

fork_test

Apr 14th, 2020
234
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4.  
  5. #define num_of_args 6
  6. #define int_base 10
  7.  
  8. struct Params {
  9.     int PI;
  10.     int IG;
  11.     int JG;
  12.     int IT;
  13.     int JT;
  14. };
  15.  
  16. int main() {
  17.     struct Params params = {5, 2, 7, 1, 1};
  18.     printf("params:\nPI:%d IG:%d JG:%d IT:%d JT:%d\n", params.PI, params.IG, params.JG, params.IT, params.JT);
  19.  
  20.     printf("parent: my id = %d\n", getpid());
  21.    
  22.     pid_t fpid;
  23.     fpid = fork();
  24.     printf("child: my id = %d\n", getpid());
  25.     printf("child: my parent id = %d\n", getppid());
  26.    
  27.     return(0);
  28. }
Advertisement
RAW Paste Data Copied
Advertisement