Earlier quoted context omitted.
Non-unix systems don't have exec; they have spawn.
Windows has exec.
Fork() without exec() is dangerous in large programs
41–50 of 106 posts
Re: Fork() without exec() is dangerous in large programs
#42Re: Fork() without exec() is dangerous in large programs
#43Re: Fork() without exec() is dangerous in large programs
#44Re: Fork() without exec() is dangerous in large programs
#45Earlier quoted context omitted.
I would like to see the reasons this comment was down-voted. It is true that fork(2) is simple and elegant design, but it involves a huge accidental complexity and hidden implications like in the original article. There is a reason that Linux has clone(2) underneath.
> It is true that fork(2) is simple and elegant design What exactly is simple and elegant about it? Have you looked into how much tooling is necessary everywhere in unix to make it work? It's insane. It has a huge footprint and it does not provide standardized APIs to make it work for non covered cases (the best we have is pthread_atfork which is not portable).
Re: Fork() without exec() is dangerous in large programs
#46Earlier quoted context omitted.
> It is true that fork(2) is simple and elegant design What exactly is simple and elegant about it? Have you looked into how much tooling is necessary everywhere in unix to make it work? It's insane. It has a huge footprint and it does not provide standardized APIs to make it work for non covered cases (the best we have is pthread_atfork which is not portable).
Fork is simple, but not easy.
Re: Fork() without exec() is dangerous in large programs
#47Earlier quoted context omitted.
Most non-UNIX OSes only have exec(), not fork(). Hence why fork() is just kind-of implemented on their POSIX compatibility layers. In UNIX it is only an issue, because IEEE doesn't want to set in stone in POSIX how threads, signals and processes should interact, due to the way threads were added to UNIX.
Non-unix systems don't have exec; they have spawn.
Re: Fork() without exec() is dangerous in large programs
#48Earlier quoted context omitted.
What is dangerous is that the interactions between threads and processes aren't part of POSIX standard and its behavior is OS specific across UNIX implementations. This isn't an issue on non-UNIX OSes.
Pthreads are part of the POSIX standard. Hence the "p". Then there is pipe() and probably some more similar ones.
For example, what happens to the interactions of signal handlers semantics and thread scheduling.
Or what happens to the threads when the process does a fork().
Re: Fork() without exec() is dangerous in large programs
#49Re: Fork() without exec() is dangerous in large programs
#504. Stop writing broken multithreaded code altogether or if you must at least run an event loop per core/thread and use a wrapper for fork() to put the system into a fork()able state before forking. It's nice and reliable.
Multithreading by itself is just not a high-level concept to be used reliably by programs.