[issue19066] os.execv fails with spaced names on Windows

anatoly techtonik report at bugs.python.org
Sun Sep 29 19:09:00 CEST 2013


anatoly techtonik added the comment:

On Sun, Sep 29, 2013 at 3:03 PM, Richard Oudkerk <report at bugs.python.org> wrote:
>
> _spawn*() and _exec*() are implemented by the C runtime library.  spawn*() and execv() are (deprecated) aliases.

It is said that execv() is deprecated, but it is not said that it is
alias of _execv(). It is only said that _execv() is C++ compliant.
http://msdn.microsoft.com/en-us/library/ms235416(v=vs.90).aspx

> The the first message is about someone's attempt to work around the problems with embedded spaces and double quotes by writing a function to escape each argument.  He says he had a partial success.

Don't we have such function already? I don't see the problem in
quoting the string.

> Surely this is basic reading comprehension?

I am mentally crippled. Sorry about that.

>> > Note that on Windows exec*() is useless: it just starts a subprocess and
>> > exits the current process.  You can use subprocess to get the same effect.
>>
>> Are you describing Windows implementation of _exec()
>> http://msdn.microsoft.com/en-us/library/431x4c1w.aspx or current
>> Python implementation?
>
> The Windows implementaion of _exec().

Does it start child process in foreground or in background? Did you
compile examples on
http://msdn.microsoft.com/en-us/library/431x4c1w.aspx page with new
VC++ to check? I don't possess the VC++ 10, so I can't do this myself.
And I believe that compiling with GCC may lead to different results.

>> > Just use subprocess instead which gets this stuff right.
>>
>> subprocess doesn't replace os.exec*, see issue19060
>
> On Unix subprocess does not replace os.exec*().  That is because on Unix exec*() replaces the current process with a new process with the *same pid*.  subprocess cannot do this.
>
> But on Windows os.exec*() just starts an independent process with a *different pid* and exits the current process.  The line
>
>     os.execv(path, args)
>
> is equivalent to
>
>     os.spawnv(os.P_NOWAIT, path, args)
>     os._exit(0)

I don't mind if it runs child process with different pid, but why it
runs new process in background. Unix version doesn't do this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19066>
_______________________________________


More information about the Python-bugs-list mailing list