title: Script to restart the PID automatically
body: <p>I was wondering if you have any scripts that take the PID of the processes that are sleeping (S) and restart it automatically</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>restart_pid() {
  # First we need to find the program's arguments
  SAVED_COMMAND="$(while IFS= read -r -d $'\0' f; do printf '%q ' "$f"; done &lt; /proc/$1/cmdline)"
  # Then we need to cd into its directory so that we stay as true to the intial conditions as possible
  cd /proc/$1/cwd
  # Now kill the process
  kill $1
  # Now we can restart the process
  eval $SAVED_COMMAND
  }
  ps -ef
  Zoho 3
  htop
  restart_pid 23924
  kill -HUP 23924</code></pre>
  </div>
  </div>
  </p>
  <p>I use a script to restart the process via the PID, but every time I need to pass the PID in the script.
  Is there any way to automate this?</p>