From: John Levon Subject: [PATCH] fix xenstored's dup2() usage Date: Wed, 5 Sep 2007 16:39:23 +0100 Message-ID: <20070905153923.GA19473@totally.trollied.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org The dup2() calls had their arguments reversed. Also remove the unnecessary close() calls. Signed-off-by: John Levon diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1952,14 +1952,14 @@ int main(int argc, char *argv[]) fflush(stdout); } - /* close stdin/stdout now we're ready to accept connections */ + /* redirect to /dev/null now we're ready to accept connections */ if (dofork) { int devnull = open("/dev/null", O_RDWR); if (devnull == -1) barf_perror("Could not open /dev/null\n"); - close(STDIN_FILENO); dup2(STDIN_FILENO, devnull); - close(STDOUT_FILENO); dup2(STDOUT_FILENO, devnull); - close(STDERR_FILENO); dup2(STDERR_FILENO, devnull); + dup2(devnull, STDIN_FILENO); + dup2(devnull, STDOUT_FILENO); + dup2(devnull, STDERR_FILENO); close(devnull); xprintf = trace; }