On Tue 25 Mar 2014 02:08:17 PM CDT, Josh Grosse wrote:
On 2014-03-25 14:49, sven falempin wrote:
# pgrep -f "dhclient: vr0 [priv] (dhclient)"
# pgrep -f "dhclient: vr0 [priv]"
# pgrep -f "dhclient: vr0"
12556
21826
Where do I kill ? (there is also a few other dhclient running)
kill(1) isn't actually required. Try:
# ifconfig vr0 down
===
TL;DR version: it doesn't appear to matter which one gets signaled with
HUP, but I can see that it might make a difference for the other
signals.
===
That actually causes problems if you need the link to stay up while
changing from DHCP to static assignment; my cable modem does weird
things every time it loses carrier on the ethernet side.
Besides, the OP was asking which process to send a signal to when he
wants to control dhclient's behaviour, not just how to terminate the
process outright.
As it happens, I agree that having a PID file is an "easy" solution for
daemons (like this) that fork and/or modify their proctitle. It's not
entirely clean, as there's no 100%-standard place to put pidfiles, and
they don't always get cleaned up correctly.
The flip side is that correct usage of pkill in the face of proctitle
alterations is far from obvious. Requiring that skill just to signal a
daemon seems to me about as sensible as requiring intimate knowledge of
find(1) just to view a directory listing.
(...says the guy who still occasionally kills entire systems by
accident when he tries to use pkill for anything complicated. I'm good
with find(1), thanks!)
On the other hand, dhclient hasn't written a pidfile since 2004 and a
missing pidfile is not exactly a common complaint.
There are two answers:
1. you can figure out which is the parent/child fairly easily
through ps(1) output. Admittedly this is not trivial to do in a
script, but certainly possible. Also, you only have to figure it out
once, then apply that pattern to "grep". e.g. " PID=$(ps alxww|awk
'$3==1 && $13~/^dhclient: vr0/ {print $2}')
2. use dhcpcd from ports/packages if you want all the bells and
whistles.
Oh. Actually, now I see sven's point - there are always at least two
processes with PPID=1 and the docs don't specify which one responds to
signals. That's a bug in the manpage, at the very least.
Sven: you should probably file a bugreport against dhclient for that,
the docs should be clear. Preferably by including a patch, but even
just suggested wording that would make sense to you is good.
--
-Adam Thompson
athom...@athompso.net