Github user Parth-Brahmbhatt commented on a diff in the pull request:

    https://github.com/apache/incubator-storm/pull/143#discussion_r13833623
  
    --- Diff: storm-core/src/clj/backtype/storm/util.clj ---
    @@ -388,13 +388,51 @@
         (catch IOException e
           (log-message "Could not extract " dir " from " jarpath))))
     
    -(defn ensure-process-killed! [pid]
    +(defn sleep-secs [secs]
    +  (when (pos? secs)
    +    (Time/sleep (* (long secs) 1000))))
    +
    +(defn sleep-until-secs [target-secs]
    +  (Time/sleepUntil (* (long target-secs) 1000)))
    +
    +(def ^:const sig-kill 9)
    +
    +(def ^:const sig-term 15)
    +
    +(defn send-signal-to-process
    +  [pid signum]
    +  (try-cause
    +    (exec-command! (str (if on-windows?
    +                          (if (== signum sig-kill) "taskkill /f /pid " 
"taskkill /pid ")
    +                          (str "kill -" signum " "))
    +                     pid))
    +    (catch ExecuteException e
    +      (log-message "Error when trying to kill " pid ". Process is probably 
already dead."))))
    +
    +(defn force-kill-process
    +  [pid]
    +  (send-signal-to-process pid sig-kill))
    +
    +(defn kill-process-with-sig-term
    +  [pid]
    +  (send-signal-to-process pid sig-term))
    +
    +(defn ensure-process-killed!
    +  [pid]
       ;; TODO: should probably do a ps ax of some sort to make sure it was 
killed
       (try-cause
    -    (exec-command! (str (if on-windows? "taskkill /f /pid " "kill -9 ") 
pid))
    +    (kill-process-with-sig-term pid)
         (catch ExecuteException e
           (log-message "Error when trying to kill " pid ". Process is probably 
already dead."))))
     
    +(defn add-shutdown-hook-with-force-kill-in-1-sec
    +  "adds the user supplied function as a shutdown hook for cleanup.
    +   Also adds a function that sleeps for a second and then sends kill -9 to 
process to avoid any zombie process in case
    +   cleanup function hangs."
    +  [func]
    +  (.addShutdownHook (Runtime/getRuntime) (Thread. #((func)
    +                                                     (sleep-secs 1)
    +                                                     (force-kill-process 
(process-pid))))))
    --- End diff --
    
    done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to