-
Notifications
You must be signed in to change notification settings - Fork 269
Support subprocess creation and management (was "fork and exec") #1987
Description
- Implement fork + equivalent clone/clone3 #2987
- Implement execve #2988
- Implement wait4 (syscall for waitpid, wait) #2989
- ? Implement vfork syscall #3123
- ? Implement execveat #3166
Supporting fork and exec would make it easier to delegate complexity to wrapper shell or python scripts instead of adding more features to Shadow itself.
e.g. rather than Shadow natively supporting compression (#1554), a user could use a config like:
-path /bin/bash
-args -c "tor | gzip -"
This could also be used to address clean shutdown of processes (#1491) with something like:
hostname:
processes:
- path: /bin/bash
args: -c "tor -f torrc & PID=$! ; sleep 100 && kill $PID"
Using killall #1986 might be a better alternative for this particular case, but a shell script would allow for greater flexibility
The biggest potential blocker right now is that not all file descriptors support duplication yet. However, unix pipes and regular files are probably sufficient to cover a lot of use cases. In the meantime we can log a warning for any file descriptors we can't duplicate into the child.