News for hackers. Stuff that matters.
Re:In C, how do you know if the dynamic allocation succeeded? by foxfluff on Saturday November 06, 2021 @05:16AM (#29128685)
If it's all syscalls (i.e. no libraries messing with hidden state) and you don't mess with parent's memory, you might be able to do this all with clone(CLONE_VM|CLONE_VFORK) instead of fork(). This is what musl uses to implement posix_spawn().
Re:In C, how do you know if the dynamic allocation succeeded? by jagrsw on Saturday November 06, 2021 @05:28AM (#29128757)
I think setenv() will use malloc() (it might use mutexes), same for error printing if it uses printf() or perror().

Also, this is all mess if fork() is called from a multi-threaded context. Esp. via clone(), which up to certain glibc() version cached getpid() result, and returned parent'd PID in the child (for performance reasons of course ;).