Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- #!/bin/bash
-
- PIDFILE=""
- PIDVAL=""
-
- pidfile() {
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
- PIDFILE="$DIR/pid"
- if [ ! -f $PIDFILE ]; then
- return PIDFILE
- else
- return ""
- fi
- }
-
- pidval() {
- pidfile
- if [ ! -z $PIDFILE ]; then
- PIDVAL =`pgrep -F "$PIDFILE"`
- else
- PIDVAL = ""
- fi
- }
-
- pidval
- if [ ! -z "$PIDVAL" ]; then
- kill -SIGTERM "$PIDVAL"
- COUNTER=500
- while [ $COUNTER -gt 0 ]; do
- pidval
- if [ -z "$PIDVAL" ]; then
- COUNTER=0
- else
- sleep 0.1
- let ((--COUNTER))
- fi
- done
- if [ ! -z $PIDVAL ]; then
- kill -SIGKILL "$PIDVAL"
- sleep 1
- fi
- fi
- pidfile
- if [ ! -z "$PIDFILE" ]; then
- rm "$PIDFILE"
- fi
|