os.fdopen giving "Invalid Argument" from pipes

T

Tim Wintle

Was wondering if someone could point out what the stupid thing I'm doing
wrong is:


{{{
import os, time
def run_multi_proc():
server_send, logger_recieve = os.pipe()
pid = os.fork()
if pid == 0:
# we are the logger
#os.close(server_send)
logger_recieve = os.fdopen(logger_recieve)
time.sleep(20)
else:
# we are the server
#os.close(logger_recieve)
server_send = os.fdopen(server_send,"w")
time.sleep(3)
os.kill(pid,signal.SIGTERM)

if __name__ == "__main__":
run_multi_proc()
}}}

python test.py

Traceback (most recent call last):
File "test.py", line 20, in <module>
run_multi_proc()
File "test.py", line 9, in run_multi_proc
logger_recieve = os.fdopen(logger_recieve)
OSError: [Errno 22] Invalid argument
Traceback (most recent call last):
File "test.py", line 20, in <module>
run_multi_proc()
File "test.py", line 15, in run_multi_proc
server_send = os.fdopen(server_send,"w")
OSError: [Errno 22] Invalid argument


really confused about why this isn't working - running on Linux with
python 2.5.2

Tim W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top