Click here to Skip to main content
15,063,596 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
int main( ) { 
    int n = 7;
    pid_t pid = fork();
    if(pid)
    {
        if(fork())
            n++;
        printf("%d\n", n);
    }
  if(fork())
    {
        n +=2;
        printf("%d\n", n);
        fork();
    }   
    printf("%d\n", n);
    return 0;     
}


What I have tried:

i have tried to think it logically but i am still beginner in this language.
Posted
Updated 14-Apr-16 8:10am
v2
Comments
Sergey Alexandrovich Kryukov 14-Apr-16 14:24pm
   
Such request makes no sense. It's not clear what you may mean by "explanation", but this is not a productive way of learning software development. In this case, learn Unix/Linux multithreading and multi-processing. It's not just language. Also learn these topics in general.

Nothing can substitute this learning. No explanation of code can help. It would be just the waste of time.

—SA

1 solution

   
Comments
CPallini 14-Apr-16 15:50pm
   
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900