| OLD | NEW |
| (Empty) | |
| 1 #!/bin/sh |
| 2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 # Sends a SIGTERM to a process whose PID is read from a pidfile. Waits 10 |
| 7 # seconds for it to exit and then sends a SIGKILL. |
| 8 |
| 9 set -e |
| 10 |
| 11 pidfile="$1" |
| 12 |
| 13 if [ -z "$pidfile" ]; then |
| 14 echo "Usage: $0 pidfile" |
| 15 exit 1 |
| 16 fi |
| 17 |
| 18 if [ ! -e "$pidfile" ]; then |
| 19 echo "Pidfile $pidfile does not exist" |
| 20 exit 0 |
| 21 fi |
| 22 |
| 23 pid=$(cat $pidfile) |
| 24 pgid=$(ps h -o pgid= $pid | awk '{print $1}') |
| 25 |
| 26 echo "Sending SIGTERM to PGID $pgid" |
| 27 kill -TERM -$pgid |
| 28 |
| 29 # Wait 10 seconds for it to exit. |
| 30 for i in $(seq 100); do |
| 31 if ! ps -p $pid > /dev/null; then |
| 32 exit 0 |
| 33 fi |
| 34 sleep 0.1 |
| 35 done |
| 36 |
| 37 echo "Sending SIGKILL to PGID $pgid" |
| 38 kill -KILL -$pgid |
| OLD | NEW |