Is there any way to create a new process which shares your file descriptor table even after an exec? clone(CLONE_FILES)
won't work, as the man page says:
If a process sharing a file descriptor table calls execve(2), its file descriptor table is duplicated (unshared).
This can be done by injecting into the child process a custom piece of code responsible for the receival of FDs and updating the child's descriptor table.
Child process should create AF_UNIX socket and recvmsg() on it, while parent process should duplicate and "stream down" the required file descriptors using sendmsg() - see here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.