So I've got a process running as root. I want it to spawn a new process running as user1, in /var/fred, with a pipe to stdin and direct stdout to /var/log/greg.
First I create the pipe, then call fork. In the child, I chdir to /var/fred, open /var/log/greg, run fdup2 on the pipe and on the handle to /var/log/greg, setuid to user1, and then finally call exec.
Show me an API that can do that without fork.
All the popen / spawn / system functions are not system calls but rather library functions which operate by calling fork.
The idea is to have several simpler system calls that you can wire together to get the complex effect you need, rather than trying to build an ultimate CreateProcess function that can handle any case of infinite complexity.
First I create the pipe, then call fork. In the child, I chdir to /var/fred, open /var/log/greg, run fdup2 on the pipe and on the handle to /var/log/greg, setuid to user1, and then finally call exec.
Show me an API that can do that without fork.
All the popen / spawn / system functions are not system calls but rather library functions which operate by calling fork.