File: kill-all-dhcp

package info (click to toggle)
netcfg 1.108+deb7u3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,464 kB
  • sloc: ansic: 5,368; sh: 176; makefile: 73
file content (16 lines) | stat: -rwxr-xr-x 294 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# Killall for dhcp clients.

for client in dhclient udhcpc pump dhcp6c; do
	pid=$(pidof $client) || true
	[ "$pid" ] || continue

	if kill -0 $pid 2>/dev/null; then
		kill -TERM $pid
		sleep 1
		# Still alive? Die!
		if kill -0 $pid 2>/dev/null; then
			kill -KILL $pid
		fi
	fi
done