summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2003-03-23 23:29:36 +0000
committermbr <mbr@FreeBSD.org>2003-03-23 23:29:36 +0000
commitc1f83c0cff3557245fad7eb0052cdbca6d918681 (patch)
tree228b4f14a99e18bf4833ff206698e090d50153dd /contrib
parentf42302072b0541d1ca22e046bbbdff3e152df36c (diff)
downloadFreeBSD-src-c1f83c0cff3557245fad7eb0052cdbca6d918681.zip
FreeBSD-src-c1f83c0cff3557245fad7eb0052cdbca6d918681.tar.gz
We don't have cat(1) and kill(1) on the miniroot disks.
This fix will be committed to the ISC repo later, but for now take this file out of the vendor tree. Reviewed by: phk Approved by: murray
Diffstat (limited to 'contrib')
-rw-r--r--contrib/isc-dhcp/client/dhclient.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c
index 96c836f..4382b05 100644
--- a/contrib/isc-dhcp/client/dhclient.c
+++ b/contrib/isc-dhcp/client/dhclient.c
@@ -94,7 +94,7 @@ int main (argc, argv, envp)
int argc;
char **argv, **envp;
{
- int i;
+ int i, e;
struct servent *ent;
struct interface_info *ip;
struct client_state *client;
@@ -111,8 +111,11 @@ int main (argc, argv, envp)
int no_dhclient_db = 0;
int no_dhclient_pid = 0;
int no_dhclient_script = 0;
+ FILE *pidfd;
+ pid_t oldpid;
char *s;
+ oldpid = 0;
/* Make sure we have stdin, stdout and stderr. */
i = open ("/dev/null", O_RDWR);
if (i == 0)
@@ -256,15 +259,18 @@ int main (argc, argv, envp)
/* first kill of any currently running client */
if (release_mode) {
- /* XXX inelegant hack to prove concept */
- char command[1024];
-#if !defined (NO_SNPRINTF)
- snprintf (command, 1024, "kill `cat %s`", path_dhclient_pid);
-#else
- sprintf (command, "kill `cat %s`", path_dhclient_pid);
-#endif
- system (command);
+ if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) {
+ e = fscanf(pidfd, "%d", &oldpid);
+
+ if (e != 0 && e != EOF) {
+ if (oldpid) {
+ if (kill(oldpid, SIGKILL) == 0)
+ unlink(path_dhclient_pid);
+ }
+ }
+ fclose(pidfd);
+ }
}
if (!quiet) {
OpenPOWER on IntegriCloud