portable fork+exec/spawn

B

Brendan Miller

I want to spawn a child process based on an external executable that I have
the path for. I then want to wait on that executable, and capture it's
output.

In the os module, fork is only supported on unix, but spawn is only
supported on windows.

The os.system call is implemented by calling the C system call, which is of
course inefficient and has portability gotchas because it calls the
underlying system shell (sh for unix, cmd for windows, and who knows what
on non unix, non windows platforms like VMS and mac os9). Most importantly,
os.system forces you to wait on the process.

Is there an actual portable means of asynchronously spawning a process and
getting a handle to it, being able to write stdin and read stdout, or does
everyone just write their own wrapper for fork and spawn?

Sorry if this post sounds a little complainy. I was just surprised to find
the os module lacking in portable abstractions over system services.

Brendan
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top