在使用 busybox 的 Linux 设备上,我使用以下 /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
但在否这杀死-15因为 udhcpc 不起作用。我添加了预先设置杀死-9所以。
这种情况不仅在 ifup/ifdown 的情况下发生,而且在我之后尝试在命令行上终止 udhcp 时也会发生。
这是一个常见问题吗?在 udhcpc 的情况下,是否值得考虑 kill -15 和 kill -9 的区别?
跟踪:
> 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320;dH4\0\0\0"..., 512) = 512
lseek(3, 399368, SEEK_SET) = 399368
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1280) = 1280
lseek(3, 397488, SEEK_SET) = 397488
read(3, "A6\0\0\0aeabi\0\1,\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\335\4SH4\0\0\0"..., 512) = 512
lseek(3, 887460, SEEK_SET) = 887460
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1480) = 1480
lseek(3, 885236, SEEK_SET) = 885236
read(3, "A4\0\0\0aeabi\0\1*\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 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 +++