Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Дана 24/09/22 07:57PM, Страхиња Радић написа: > Дана 24/09/22 07:20PM, bi...@iscarioth.org написа: > > malloc(13);/* <--- what will happen, a leak, it > > will be freed ? */ > > That will cause a memory leak. Every successful allocation needs to > have a corresponding call to f

Re: Need some information about fork(2)

2024-09-22 Thread Ingo Schwarze
Hello, s...@strahinja.org wrote on Sun, Sep 22, 2024 at 10:35:42PM +0200: > Still, while most OSes (including OpenBSD) do free the leaked memory > on program termination, there are some which don't.[1] > [1]: https://stackoverflow.com/a/2975844/184064 I think you are spreading fear, uncertainty,

Re: Need some information about fork(2) -- Pedantic Correction

2024-09-22 Thread Jay F. Shachter
> > It's an exact copy, all memory allocations remain the same. > Please forgive the pedantic correction, but, although I don't know how OpenBSD does it, I certainly hope that OpenBSD does it the way other operating systems do it: the memory in the child process is not "an exact copy" -- the me

Re: Need some information about fork(2)

2024-09-22 Thread bilal
Thanks for your answers ! Each information from both of you are interesting ! Sorry for disturbing and take a lot from your free times. On 2024-09-22T21:08:04.000+02:00, Otto Moerbeek wrote: > On Sun, Sep 22, 2024 at 08:07:54PM +0200, Страхиња Радић wrote: > > > >Дана 24/09/22 07:59PM,

How is OpenBSD on the Windows Dev Kit 2023?

2024-09-22 Thread adrian celeste
Hello, I was wondering if anyone was running OpenBSD on their Windows Dev Kit 2023, and if so, do you have any trouble/pain points with it. I have one currently running windows, but if vmm/vmd eventually run on arm64 it would make a nice little virtualization machine.

Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Дана 24/09/22 07:20PM, bi...@iscarioth.org написа: > malloc(13);/* <--- what will happen, a leak, it > will be freed ? */ That will cause a memory leak. Every successful allocation needs to have a corresponding call to free(3). Check malloc(3) for more details. In particular,

Re: Need some information about fork(2)

2024-09-22 Thread Otto Moerbeek
On Sun, Sep 22, 2024 at 08:07:54PM +0200, Страхиња Радић wrote: > Дана 24/09/22 07:59PM, Страхиња Радић написа: > > Of course, that would cause a memory leak if the memory was assigned to > > a variable, like this: > > > > char* tmp = malloc(13); > > > > otherwise, like this: > > > > m

Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Дана 24/09/22 07:59PM, Страхиња Радић написа: > Of course, that would cause a memory leak if the memory was assigned to > a variable, like this: > > char* tmp = malloc(13); > > otherwise, like this: > > malloc(13); > > the result is discarded and a warning is printed if the program

Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Дана 24/09/22 09:08PM, Otto Moerbeek написа: > All correct, but still, on process exit all resources used by a > program are cleaned up. In that sense it is not a memory leak to not > call free. Especially for one-time allocations. Still, while most OSes (including OpenBSD) do free the leaked memo

Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Dear Ingo, While I agree with what you said, the decision of whether to free the successful allocations in a program is not trivial. If nothing else, opposed to the "fear" (as you put it) of not having the memory freed on program exit is the other extreme: the inertia and complacency of not doing

Re: pkgconfig errors

2024-09-22 Thread Страхиња Радић
Дана 24/09/22 07:55AM, Jesse Lawton написа: > Done. > > Thanks > Jesse Lawton > /usr/obj/ports/pkgconf-1.6.3/pkgconf-1.6.3/libpkgconf/dependency.c:115 > [pkgconf_dependency_t *add_or_replace_dependency_node(const pkgconf_client_t > *, pkgconf_dependency_t *, pkgconf_list_t *)]: added dependency

Need some information about fork(2)

2024-09-22 Thread bilal
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 allocate

Re: Need some information about fork(2)

2024-09-22 Thread Otto Moerbeek
On Sun, Sep 22, 2024 at 10:08:56AM +0200, bi...@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,

Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Attached is an example C program using fork(2). It dynamically allocates a string array with malloc(3), then forks. Child free(3)s the array, sleep(3)s for 3 seconds, then exits. Parent wait(2)s for children, then prints the array. The array in the parent is not affected by free(3) in the child

Re: Need some information about fork(2)

2024-09-22 Thread Otto Moerbeek
On Sun, Sep 22, 2024 at 05:33:36PM +0200, bi...@iscarioth.org wrote: > Sorry for disturbing you, again... > > Does it means we should also free virtual memory from the child > process before exiting ? All resources used by a process are freed automatically when the process ends. Typically, a for

Re: Need some information about fork(2)

2024-09-22 Thread bilal
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 wrote: > On Sun, Sep 22, 2024 at 05:33:36PM +0200, bi...@iscarioth.org wrote: > 

Re: Need some information about fork(2)

2024-09-22 Thread Страхиња Радић
Дана 24/09/22 05:53PM, bi...@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 i

Re: Need some information about fork(2)

2024-09-22 Thread bilal
On 2024-09-22T18:40:44.000+02:00, Страхиња Радић wrote: > Attached is an example C program using fork(2). It dynamically > allocates a string array with malloc(3), then forks. Child free(3)s the > array, sleep(3)s for 3 seconds, then exits. Parent wait(2)s for > children, then prints the arra

Re: Need some information about fork(2)

2024-09-22 Thread bilal
Sorry for disturbing you, again... Does it means we should also free virtual memory from the child process before exiting ? On 2024-09-22T10:27:56.000+02:00, Otto Moerbeek wrote: > On Sun, Sep 22, 2024 at 10:08:56AM +0200, bi...@iscarioth.org wrote: >  >>  Hello OpenBSD team >>   >>   I'm havin