Regarding fork system call in linux

Ok, I work with the following C / C ++ code on Linux:

int main() {
    printf("hello");
    Pid = fork();
    if (pid > 0)
            printf("I’m the parent!");
    else
            printf("I’m the child");
    return 0;
}

Here is my conclusion: program screenshot

My notes from my CS professor say the following:

After creating a new child process, both processes will execute the next instruction after the system call fork(). Please note that Unix will make an exact copy of the parent address space and provide it for the child. Therefore, the parent and child processes have separate address spaces.

, , ""? , , , - , , " " , .

+4
1

printf, . , fflush \n printf.

fflush \n, . , , .

C99 7.19.2p2

, .

, , . , undefined.

+5

Source: https://habr.com/ru/post/1686928/


All Articles