Skip to content

Instantly share code, notes, and snippets.

@collinalexbell
Last active September 11, 2016 10:44
Show Gist options
  • Save collinalexbell/5ebb6de506345303cd06b8df9da91484 to your computer and use it in GitHub Desktop.
Save collinalexbell/5ebb6de506345303cd06b8df9da91484 to your computer and use it in GitHub Desktop.
hideos pid kill in clojure
#!/bin/bash
ps -A | grep pocketsphinx_continuous | grep -v grep | awk '{print $1}'
(async/go (shell/sh "sh" "src/dameon/brochas_area/launch_sphinx.sh"))
(defn get-pocket-sphinx-pids []
(clojure.string/split
(get (shell/sh "sh" "src/dameon/brochas_area/get_pid.sh") :out)
#"\n"))
(defn kill-pocket-sphinx []
(doall (map #(shell/sh "kill" "-9" %) (get-pocket-sphinx-pids))))
@pbzdyl
Copy link

pbzdyl commented Sep 11, 2016

I would rather use (future ...) to run something on a separate thread. async/go is meant to be used with channels so different go blocks can communicate with each other.

But I would still go with Raynes/conch approach as you don't need any additional external shell scripts for piping, getting PID etc. You can just setup the whole command and execute it with timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment