Is it possible to open up a file descriptor in my program. And then pass it to a child process for use (along with permissions)? I know each process has it's own list of descriptors, so I don't know how this would be done.
Printable View
Is it possible to open up a file descriptor in my program. And then pass it to a child process for use (along with permissions)? I know each process has it's own list of descriptors, so I don't know how this would be done.
yes. This is common. What many programs do is to open some file to which they need access and then chroot and change userID (to a lesser user) to do processing. This is for security's sake.
File descriptors remain valid after a call to fork(). Normally, they also remain valid after a call to exec(), unless the FD_CLOEXEC flag is set of that descriptor.
So the answer is yes.
Great. Thanks.
I didn't know exec() did that.