fork download
  1. #include<stdio.h>
  2. #include<sys/types.h>
  3. #include<unistd.h>
  4. int main(){
  5. pid_t pid;
  6. pid=fork();
  7. if(pid==0){
  8. printf("I am Child Process %d",getpid());
  9. printf("priority :%d,id: %d",nice(7),getpid());
  10. }
  11. else{
  12. printf("I am Parent Process %d",getpid());
  13. printf("priority :%d,id: %d",nice(15),getpid());
  14.  
  15.  
  16. }
  17. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
I am Parent Process 2358020priority :19,id: 2358020I am Child Process 2358023priority :19,id: 2358023