Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On the opposite end of running inside a Docker Container, in a VM, on a Cloud Server, this adds support for running under NoMMU environments.
fork() is not usable under NoMMU because we can't map a separate process into the identical memory address. Instead we will vfork(). We also need a statically linked position independent executable.
The challenge is that technically, until execvp() is called, both the child and the parent share the same memory space, kind of like a thread, but more dangerous because of the shared stack. Technically, we shouldn't be calling other functions like sigprocmask(), setsid(), strerror(), fprintf(), and ioctl() between the vfork() and execvp(). However, the alternative posix_spawnp(), doesn't seem to support making an ioctl, which we need for attaching to a controlling TTY. If we dropped that, it could be used. However, while not strictly guaranteed by the spec, I think this is pretty safe. We aren't overwriting any crazy memory locations or mucking with the stack frame by returning. Under vfork(), the parent is blocked until the execvp() succeeds or the child exits. Therefore, we shouldn't have problems with race conditions. exit() can't be used because it will flush buffers and make calls to registered on-exit handlers with libc within the shared memory space. Therefore, I replaced them with _exit().
Let me know what you think.