Can somone please explain to me what does fork() != 0 mean? From what I understand I think it means if fork is not false? Or if fork is true then.... I dont understand how Fork() can be true or false, seeing that it just creates a copy of a process into a parent and child.
1 #include "csapp.h"
3 int main()
5 int x = 3;
7 if (Fork() != 0)
8 printf("x=%d\n", ++x);
10 printf("x=%d\n", --x);
EDIT: Also if a program where to say "if (Fork() == 0)" what would that mean?
The return value of fork() will explain your questions
On success, the PID of the child process is returned in the parent, and 0
is returned in the child. On failure, -1 is returned in the parent, no
child process is created, and errno is set appropriately.
can anyone give me nice tutorial of this fork() ? I just know only one thing which gerard said. i want to ask where is child process which is created ? This process is parent one. and how can we deal with child one ? hoping for best answers . ;)