File: kill-all-dhcp

package info (click to toggle)
netcfg 1.160
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,532 kB
  • sloc: ansic: 5,361; sh: 183; makefile: 77
file content (16 lines) | stat: -rwxr-xr-x 294 bytes parent folder | download | duplicates (7)
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