Em um dispositivo Linux usando o busybox eu uso o seguinte / etc / network / interfaces
...
# Wired interface eth0 is using dhcp, enabled while system start
auto eth0
iface eth0 inet dhcp
pre-up [ -n "$(cat /var/run/udhcpc.eth0.pid 2> /dev/null)" ] && \
kill -9 $(cat /var/run/udhcpc.eth0.pid) || true
pre-up /bin/grep -v -e "ip=[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" \
/proc/cmdline > /dev/null
post-down [ -n "$(cat /var/run/udhcpc.eth0.pid 2> /dev/null)" ] && \
kill -15 $(cat /var/run/udhcpc.eth0.pid) || true
post-down ip addr flush dev eth0 || true
Mas, em ifdown eth0 , o kill -15 para o udhcpc não está funcionando. Eu adicionei o pre-up kill -9 portanto.
Isso acontece não apenas no caso de ifup / ifdown mas também se eu tentar matar o udhcp na linha de comando depois.
Isso é um problema comum? Vale a pena pensar na diferença de matar -15 contra kill -9 no caso de udhcpc?
strace:
> strace kill -15 2110
execve("/bin/kill", ["kill", "-15", "2110"], [/* 15 vars */]) = 0
brk(0) = 0x8e000
uname({sys="Linux", node="am335x-evm", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f59000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|S_ISGID|0644, st_size=14548, ...}) = 0
mmap2(NULL, 14548, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f55000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/tls/v7l/neon/vfp/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
...
open("/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%(%pre%%pre%%pre%%pre%0;dH4%pre%%pre%%pre%"..., 512) = 512
lseek(3, 399368, SEEK_SET) = 399368
read(3, "%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%"..., 1280) = 1280
lseek(3, 397488, SEEK_SET) = 397488
read(3, "A6%pre%%pre%%pre%aeabi%pre%,%pre%%pre%%pre%%pre%57-A%pre%\nA\t\n"..., 55) = 55
fstat64(3, {st_mode=S_IFREG|S_ISGID|0644, st_size=400648, ...}) = 0
mmap2(0x48640000, 430264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x48640000
mprotect(0x486a1000, 28672, PROT_NONE) = 0
mmap2(0x486a8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x60) = 0x486a8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%(%pre%%pre%%pre%%pre%5SH4%pre%%pre%%pre%"..., 512) = 512
lseek(3, 887460, SEEK_SET) = 887460
read(3, "%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%"..., 1480) = 1480
lseek(3, 885236, SEEK_SET) = 885236
read(3, "A4%pre%%pre%%pre%aeabi%pre%*%pre%%pre%%pre%%pre%57-A%pre%\nA\t\n"..., 53) = 53
fstat64(3, {st_mode=S_IFREG|0755, st_size=888940, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f54000
mmap2(0x48518000, 928112, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x48518000
mprotect(0x485ed000, 32768, PROT_NONE) = 0
mmap2(0x485f5000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd5) = 0x485f5000
mmap2(0x485f9000, 6512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x485f9000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f53000
set_tls(0xb6f534c0, 0xb6f53b98, 0x4847f048, 0xb6f534c0, 0xb6f54500) = 0
mprotect(0x485f5000, 8192, PROT_READ) = 0
mprotect(0x486a8000, 4096, PROT_READ) = 0
mprotect(0x4847e000, 4096, PROT_READ) = 0
munmap(0xb6f55000, 14548) = 0
getuid32() = 0
getpid() = 4931
kill(2110, SIGTERM) = 0
exit_group(0) = ?
+++ exited with 0 +++