argos83 / pysphere

Automatically exported from code.google.com/p/pysphere
88 stars 76 forks source link

vm.list_processes() #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. pid = self.vm.start_process(r'c:\windows\system32\calc.exe', arg)
2. vm.list_processes() >>> pid found as expected.
3. kill the process.
4. vm.list_processes() >>> pid still being listed.

That's an error i guess.

pysphere 0.1.7, Python 2.6, ESXi 5.0, Windows XP SP3 guest, Windows 7 64bits 
host.

I'm writing a function to start process in guest and wait until process be dead.

Original issue reported on code.google.com by glauberf...@gmail.com on 27 Mar 2013 at 2:44

GoogleCodeExporter commented 9 years ago
I had the same issue until I saw this in the list_process() documentation:

exit_code [int]: If the process was started using start_process then
        the process exit code will be available if queried within 5
        minutes after it completes. None otherwise

So looking for the PID is not enough. You have to also check for 'exit_code' 
being present in the process dictionary. If it's there, the process has 
finished.

Original comment by aszek...@countertack.com on 25 Apr 2013 at 10:00

GoogleCodeExporter commented 9 years ago
That's right. That behavior is defined by vmware 
(http://pubs.vmware.com/vsphere-51/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.
guest.ProcessManager.html)

As mentioned, you'll need to check the exit code as well.

Original comment by argo...@gmail.com on 26 Apr 2013 at 2:19