spawn syntax + os.P_WAIT mode behavior + spawn stdout redirection

Peter Hansen peter at engcorp.com
Thu Jan 20 20:59:35 EST 2005


Derek Basch wrote:
> If the syntax of spawnl is:
> 
> spawnl(mode, path, ...)
> 
> Why does everyone write it like:
> 
> os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')
> 
> or:
> 
> os.spawnl(os.P_WAIT, "/var/www/db/smm/smm_train", "smm_train",
> "SMMTrainInput.xml")
> 
> How is the first 'cp' a path to a file? why does the desired executable have to
> be named again as the first parameter?

Marginally educated guessing:

1. "cp" is a shell command, so no path is required or possible.

2. The repetition of the executable name is so that argv[0] can
    have the expected contents: the name of the executable.

-Peter



More information about the Python-list mailing list