By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

[win32] spawn background process and detach it w/o problems

P: n/a
Hello!
How to write portable (win32, unix) script that launches another
program and continues its execution?

I've looked at spawn*() but it doesn't look in PATH dirs on windows so
it's totally unusable when you don't know where exactly program is.

I've looked at fork() way but there's no fork for windows.

My current solution is
thread.start_new(os.system, (<here's program to launch>,))

It's ugly and there's one big unpleasant pecularity:
in case there were any os.chdir()-s between beginning of script
execution and that thread.start_new() then new thread starts in
original directory. Not in current directory at moment of
thread.start_new()
Nov 8 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Nov 8, 8:09 am, "Dmitry Teslenko" <dtesle...@gmail.comwrote:
Hello!
How to write portable (win32, unix) script that launches another
program and continues its execution?

I've looked at spawn*() but it doesn't look in PATH dirs on windows so
it's totally unusable when you don't know where exactly program is.

I've looked at fork() way but there's no fork for windows.

My current solution is
thread.start_new(os.system, (<here's program to launch>,))

It's ugly and there's one big unpleasant pecularity:
in case there were any os.chdir()-s between beginning of script
execution and that thread.start_new() then new thread starts in
original directory. Not in current directory at moment of
thread.start_new()
Take a look at the subprocess module.

Nov 8 '07 #2

P: n/a
Hello!

On 08/11/2007, da*********@gmail.com <da*********@gmail.comwrote:
Take a look at the subprocess module.
Big thanks!

It's interesting what's happening with subprocess.Popen instance after
it has been instatiated and script's main thread exits leaving
Popen'ed application open.
Nov 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.