Lars Kotthoff wrote: > This prints out "foo" twice although it's only written once to the pipe. It > seems that python doesn't flush file descriptors before copying them to the > child process, thus resulting in the duplicate message. The equivalent C > program behaves as expected, Your Python and C programs are not equivalent -- the C one is writing directly to the file descriptor, whereas the Python one is effectively using a buffered stdio stream. The unflushed stdio buffer is getting copied by the fork, hence the duplicate output. Solution: either (a) flush the Python file object before forking or (b) use os.write() directly on the fd to avoid the buffering. -- Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4