Sunday, September 22, 2024

Re: Need some information about fork(2)

Дана 24/09/22 05:53PM, bilal@iscarioth.org написа:
> So if I understand well, if a fork(2) come with execve(2) it freed
> automatically the resources. However if fork(2) come with any
> allocator, I should take care of it ?

The parent and child processes are two separate processes, the child
the identical copy of the parent process, at the time when fork(2) was
called, in a separate memory space. Whatever you normally do
(malloc(3), free(3)) in a program you should do in a forked process.

Think of file copy - the two files are identical. Editing one file has
no impact on its copy.

No comments:

Post a Comment