From b86b6a7bc7fe839cc3e2741c86b1049eab5f9332 Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Sun, 29 Aug 2004 18:57:31 +0000 Subject: [PATCH] * background.c (do_background): Fixed file descriptor leak. --- src/ChangeLog | 4 ++++ src/background.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index fb7497cdc..77f45a733 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-08-29 Roland Illig + + * background.c (do_background): Fixed file descriptor leak. + 2004-08-29 Roland Illig * Code cleanup: Added const qualifier for variables and diff --git a/src/background.c b/src/background.c index 30e86dba7..779564cb8 100644 --- a/src/background.c +++ b/src/background.c @@ -116,8 +116,13 @@ do_background (struct FileOpContext *ctx, char *info) if (pipe (comm) == -1) return -1; - if ((pid = fork ()) == -1) + if ((pid = fork ()) == -1) { + int saved_errno = errno; + (void) close (comm[0]); + (void) close (comm[1]); + errno = saved_errno; return -1; + } if (pid == 0) { int nullfd;