busybox' udhcpc can not be killed

1

2

On an linux device using busybox I use the following /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

But on ifdown eth0 the kill -15 for udhcpc is not working. I added the pre-up kill -9 therefore.

This happens not only in case of ifup/ifdown but also if I try to kill the udhcp on commandline afterwards.

Is this a common issue? Is it worth to think about the difference of kill -15 versus kill -9 in case of 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, "\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 +++

Th. Thielemann

Posted 2017-04-28T10:54:23.393

Reputation: 141

It's not a common issue, kill 15 (SIGTERM) should work. Can you show us strace kill ... output? – Arkadiusz Drabczyk – 2017-04-28T11:59:02.570

I took a look at the source code and there's nothing that would suggest that kill -9 won't work. Does it happen on the stock busybox? – Arkadiusz Drabczyk – 2017-04-28T15:31:24.513

kill -9 works but I assumed the right way is to use SIGTERM it instead of SIGKILL. Thus I will use SIGKILL. – Th. Thielemann – 2017-04-28T16:21:29.343

You're right, SIGTERM should work. There is something wrong going on. Let me ask again: is it an upstream version busybox? Did you compile it on your own? If no, where did you get it from? I tried it locally and kill without an argument kills udhcpc. Yet another question - does udhcpc have the same PID every time? It might be automatically respawned by init or something else. – Arkadiusz Drabczyk – 2017-04-28T19:29:14.250

I compiled it by my own. And sometimes it works to kill it with SIGTERM but sometimes not. The PID is everytime the same - a process which is not running anymore. – Th. Thielemann – 2017-05-02T06:44:40.150

No answers