summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-04-20 21:25:08 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-04-20 21:25:08 +0000
commitdfc691e80928339783587845ab82af2504714f30 (patch)
tree163a1193d7e4e8a631198a0a858c6dba9f50374d /sbin/dhclient/dhclient.c
parentd83d30bd8e4d4f8e9f4f7ad86d95f26855babd79 (diff)
Make -L even more useful to monitoring processes. Truncate and
refill the file rather than creating a new one, which preserves an fd being monitored. And truncate file on losing link. Things like sysutils/ertn should now be able to see new leases, lease renewals and cable unplugs. tweaks by and ok sthen@
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index b0def3be04f..8f50b17c8b4 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.297 2014/04/17 13:46:48 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.298 2014/04/20 21:25:07 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -348,6 +348,11 @@ routehandler(void)
client->state = S_REBOOTING;
state_reboot();
} else {
+ /* Let monitoring programs see link loss. */
+ write_file(path_option_db,
+ O_WRONLY | O_CREAT | O_TRUNC | O_SYNC |
+ O_EXLOCK | O_NOFOLLOW, S_IRUSR | S_IWUSR |
+ S_IRGRP, 0, 0, "", 0);
/* No need to wait for anything but link. */
cancel_timeout();
}
@@ -1955,10 +1960,11 @@ fork_privchld(int fd, int fd2)
close(fd);
if (strlen(path_option_db)) {
- rslt = unlink(path_option_db);
+ /* Truncate the file so monitoring process see exit. */
+ rslt = truncate(path_option_db, 0);
if (rslt == -1)
- warning("Could not unlink '%s': %s",
- path_option_db, strerror(errno));
+ warning("Unable to truncate '%s': %s", path_option_db,
+ strerror(errno));
}
/*