I use python3.4's os.pipe to do IPC bettwen father process and child process, passing the pipe args by os.execlp args
self.child_pipe_read=int(sys.argv[2])
self.child_pipe_write=int(sys.argv[3])
...
os.execlp('python3','python3','child_test.py',str(pid),str(self.child_pipe_read) ,str(self.child_pipe_write))
however,when I use this:
msg=os.read(self.child_pipe_read,32)
throw Error OSError: [Errno 9] Bad file descriptor
and then I try to write to the pipe:
os.write(self.parent_pipe_write,(msg+'\n').encode())
BrokenPipeError: [Errno 32] Broken pipe
I saw the python3.4's doc,find this:
"Changed in version 3.4: The new file descriptors are now non-inheritable" but I don't know What's the meaning of it? How can I IPC with pipe?
It is considered a security vulnerability to allow FDs to be inherited by default, hence the change for Python 3.4. You must explicitly mark the FD as inheritable by calling os.set_inheritable(fd, True)
. Note that this function is new in Python 3.4.
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.