From 06cb5f26f7b42b5c7e34f13bcece5a22c6b76e8b Mon Sep 17 00:00:00 2001 From: "David E. O'Brien" Date: Mon, 16 Jul 2001 01:56:48 +0000 Subject: [PATCH] Connect std{in,out,err} to *something* so that "hooks" scripts that write to std{err,out} will not spam /etc/resolv.conf. Ted Lemon fixed the problem in version 3 of the client, but only for the pre-daemonized case. Thanks to Brian for pointing that out and helping to make our future dhclient (v3) better. Submitted by: brian --- contrib/isc-dhcp/client/dhclient.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c index 69424a80ff1..a84acb31a3a 100644 --- a/contrib/isc-dhcp/client/dhclient.c +++ b/contrib/isc-dhcp/client/dhclient.c @@ -2121,6 +2121,13 @@ int script_go (ip) wstatus = 0; } } else { + if ((i = open(_PATH_DEVNULL, O_RDWR)) != -1) { + dup2(i, STDIN_FILENO); + dup2(i, STDOUT_FILENO); + dup2(i, STDERR_FILENO); + if (i > STDERR_FILENO) + close(i); + } execve (scriptName, argv, envp); error ("execve (%s, ...): %m", scriptName); exit (0);