DestroyProcess 769 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. # shellcheck shell=bash
  3. # ``````````````````````````````````````````````````````````````````````````````
  4. # Function name: DestroyProcess()
  5. #
  6. # Description:
  7. # It destroys currently running tor process.
  8. #
  9. # Usage:
  10. # DestroyProcess "id"
  11. #
  12. # Examples:
  13. # DestroyProcess ${_tpr}"
  14. #
  15. function DestroyProcess() {
  16. local _FUNCTION_ID="DestroyProcess"
  17. local _STATE=0
  18. local _arg_tproc="$1"
  19. # shellcheck disable=SC2154
  20. kill -9 "$_arg_tproc" >>"$_log_stdout" 2>&1 ; _kstate="$?"
  21. if [[ $_kstate -eq 0 ]] ; then
  22. _logger "info" \
  23. "${_FUNCTION_ID}()" \
  24. "killed tor process: '${_arg_tproc}'"
  25. else
  26. _logger "warn" \
  27. "${_FUNCTION_ID}()" \
  28. "not killed tor process (maybe not found?)"
  29. fi
  30. return $_STATE
  31. }