I am learning fork() in Linux, and here is my program:
1 #include
2 #include
3 #include
4 int main(
I suppose that, sometimes, a race condition happens, and the parent dies before the child. Hence, the child becomes children from init process. In your case, that must be systemd.
Anyway, be advised that running fork(); fork();
will produce 4 processes, which is (probably) not what you intend. Use control structure as you did with the first one to have fine control on the behaviour of your program.