Search code examples
windowschef-infrasysinternals

How to wait for a process to be gone in chef (Windows)


I would like to make sure chef waits if a process is still running before continuing. How to do that on Windows?


Solution

  • As mentioned here a smart use of execute resource can be employed, i.e. to wait for TiWorker.exe process to complete before continuing:

    execute "Wait until TiWorker is not present" do
       command "c:/Sysinternals/pslist /accepteula TiWorker"
       retries 30
       returns 1
       retry_delay 10
       timeout 10
    end
    

    where pslist is pslist