Sunday, September 22, 2024

Re: Need some information about fork(2)

On Sun, Sep 22, 2024 at 10:08:56AM +0200, bilal@iscarioth.org wrote:

> Hello OpenBSD team
>
> I'm having a little trouble understanding how this works.
>
> of fork(2), according to man. It's an exact copy of the parent
> process.
>
> There are limitations that are explicit in the man. However,
>
> I wanted to know if the pointers we use are the same.
>
> For example, if I had allocated 4 bytes in my parent process, I would
> launch the fork...
>
> If I release this address from the child, is the father's pointer
> still intact, or is it released?
>
> Translated with DeepL.com (free version)

It's an exact copy, all memory allocations remain the same. The trick
is the new process virtual memory space is seperate, so the equal
pointer actually refer to different sets of memory (each process has
it's onwn virual memory space). So an allocatoon or free done by the
parent or child does not interfere with the other process.

-Otto

No comments:

Post a Comment