You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

send.sh 829B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # Copyright (c) 2014 The Bitcoin Core developers
  3. # Distributed under the MIT/X11 software license, see the accompanying
  4. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. TIMEOUT=10
  6. SIGNAL=HUP
  7. PIDFILE=.send.pid
  8. if [ $# -eq 0 ]; then
  9. echo -e "Usage:\t$0 <cmd>"
  10. echo -e "\tRuns <cmd> and wait ${TIMEOUT} seconds or until SIG${SIGNAL} is received."
  11. echo -e "\tReturns: 0 if SIG${SIGNAL} is received, 1 otherwise."
  12. echo -e "Or:\t$0 -STOP"
  13. echo -e "\tsends SIG${SIGNAL} to running send.sh"
  14. exit 0
  15. fi
  16. if [ $1 = "-STOP" ]; then
  17. if [ -s ${PIDFILE} ]; then
  18. kill -s ${SIGNAL} $(<$PIDFILE 2>/dev/null) 2>/dev/null
  19. fi
  20. exit 0
  21. fi
  22. trap '[[ ${PID} ]] && kill ${PID}' ${SIGNAL}
  23. trap 'rm -f ${PIDFILE}' EXIT
  24. echo $$ > ${PIDFILE}
  25. "$@"
  26. sleep ${TIMEOUT} & PID=$!
  27. wait ${PID} && exit 1
  28. exit 0