Hello, https://github.com/apache/nuttx/pull/19562
Currently, in NuttX, fork() and vfork() do the same thing. The child shares .data, .bss and the heap with the parent. The child also runs at the same time as the parent. This is the behaviour of vfork(), not of fork(). A program that uses POSIX fork() compiles and runs. But the child writes into the variables of the parent. There is no error message. This pull request gives each function its own behaviour. It is a breaking change. It removes fork() from all architectures. unistd.h no longer declares fork(), so a call to fork() now fails to build. Each architecture can add fork() again later, with the correct behaviour (which requires MMU). This is step 1 of the plan in issue #19540. vfork() keeps its behaviour. These architectures now have vfork(): ARM 32-bit, ARM64, RISC-V and x86_64 in all build modes; SIM, but not on Windows; MIPS32. The kernel builds of ARM 32-bit, ARM64 and x86_64 are new. Please test vfork() on your board. CI builds this branch, but CI does not run vfork() on hardware. This patch changes the address environments, the stack setup and the register context of each architecture. I tested 24 configurations with QEMU and two on real hardware. Do these steps: 1. Get this branch and apache/nuttx-apps#3685. 2. Build your configuration. 3. Run ostest. The vfork() test is the first test. It writes this line: vfork_test: Child 5 ran and exited before the parent resumed Send the target, the build mode and this line. A report of a failure is as useful as a report of a pass. Comments on the semantics are also welcome. Thank you, Marco Casaroli
