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 ?
On 2024-09-22T17:42:28.000+02:00, Otto Moerbeek <otto@drijf.net> wrote:
On Sun, Sep 22, 2024 at 05:33:36PM +0200, bilal@iscarioth.org wrote:Sorry for disturbing you, again...Does it means we should also free virtual memory from the childprocess before exiting ?All resources used by a process are freed automatically when theprocess ends. Typically, a fork in the child is followed by anexecve(2) call, which replaces the current process by a new one, whithonly a few things inherited.-OttoOn 2024-09-22T10:27:56.000+02:00, Otto Moerbeek <otto@drijf.net>wrote:On Sun, Sep 22, 2024 at 10:08:56AM +0200, bilal@iscarioth.org wrote:Hello OpenBSD teamI'm having a little trouble understanding how this works.of fork(2), according to man. It's an exact copy of the parentprocess.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, Iwouldlaunch the fork...If I release this address from the child, is the father's pointerstill intact, or is it released?It's an exact copy, all memory allocations remain the same. Thetrickis the new process virtual memory space is seperate, so the equalpointer actually refer to different sets of memory (each process hasit's onwn virual memory space). So an allocatoon or free done by theparent or child does not interfere with the other process.-Otto
No comments:
Post a Comment