Last active
September 11, 2016 10:44
-
-
Save collinalexbell/5ebb6de506345303cd06b8df9da91484 to your computer and use it in GitHub Desktop.
hideos pid kill in clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ps -A | grep pocketsphinx_continuous | grep -v grep | awk '{print $1}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would rather use
(future ...)
to run something on a separate thread.async/go
is meant to be used with channels so differentgo
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.