Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

return codes from os.spawn

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


nirmaljs at lasonindia

Sep 17, 2007, 4:17 AM

Post #1 of 2 (84 views)
Permalink
return codes from os.spawn

Hi,

When I try running java through os.spawnv with P_NOWAIT, it returns the
process id

>>> os.spawnv(os.P_NOWAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
ex3178 true'))
19524

then I removed the command line parameter in the java command to fail ( it
should throw an exception) the process and ran it. This time also it
returned the process id .

>>> os.spawnv(os.P_NOWAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
ex3178'))
21947


And I tried the same by using P_WAIT and it returned the same exit code

>>> os.spawnv(os.P_WAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
ex3178 true))
127
>>> os.spawnv(os.P_WAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
ex3178'))
127


please let me know how can we identify that the process is completed
successfully or not ?

Thanks,
Nirmal




--
http://mail.python.org/mailman/listinfo/python-list


gagsl-py2 at yahoo

Sep 17, 2007, 12:16 PM

Post #2 of 2 (69 views)
Permalink
Re: return codes from os.spawn [In reply to]

En Mon, 17 Sep 2007 08:17:22 -0300, Nirmal <nirmaljs[at]lasonindia.com>
escribi�:

> Hi,
>
> When I try running java through os.spawnv with P_NOWAIT, it returns the
> process id
>
>>>> os.spawnv(os.P_NOWAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
> ex3178 true'))
> 19524
>
> then I removed the command line parameter in the java command to fail
> ( it
> should throw an exception) the process and ran it. This time also it
> returned the process id .
>
>>>> os.spawnv(os.P_NOWAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
> ex3178'))
> 21947
>
>
> And I tried the same by using P_WAIT and it returned the same exit code
>
>>>> os.spawnv(os.P_WAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
> ex3178 true))
> 127
>>>> os.spawnv(os.P_WAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java
> ex3178'))
> 127

> please let me know how can we identify that the process is completed
> successfully or not ?

All your examples fail to execute your program. The second argument is the
program being executed, not only the directory. Should be the same as the
first element of `args`. And the individual arguments should be separated.

os.spawnv(os.P_WAIT, '$JAVA_HOME/bin/java', ['$JAVA_HOME/bin/java',
'ex3178', 'true'])

In this case it's easier to use spawnl:

os.spawnl(os.P_WAIT, '$JAVA_HOME/bin/java', 'java', 'ex3178', 'true')


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.