Haythm
Haythm

Reputation: 1

Why different outputs come in AppCode from Terminal when using fork()?

When I try to run an example code about fork() I get different output in AppCode than in terminal.

This is one of the functions I tried to use

 /*
 * fork3 - Three consective forks
 * Parent and child can continue forking
 */
void fork3()
{
    printf("L0\n");
    fork();
    printf("L1\n");
    fork();
    printf("L2\n");
    fork();
    printf("Bye\n");
}

And this is the different outputs I get

Screenshots:

Terminal:

AppCode:

And this happen to almost all functions in the educational code about fork().

Upvotes: 0

Views: 36

Answers (1)

LaszloLadanyi
LaszloLadanyi

Reputation: 973

I have not used AppCode, but it looks like it displays only the output of the process that was started from appcode and does not display the output of the forked children. On the other hand on the terminal you get the output for all.

Upvotes: 1

Related Questions