aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-30 23:07:22 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-30 23:07:22 +0100
commit37c958a639fa0c9ed2cca7f3c505f9f644b3070e (patch)
treea1222990e3fe15320d2e9d8faeef6c8cd2ec2aad /src
parentSIGKILL and SIGSTOP cannot be cought, for you get an exception even if SIG_DFL is used (diff)
downloadslibc-37c958a639fa0c9ed2cca7f3c505f9f644b3070e.tar.gz
slibc-37c958a639fa0c9ed2cca7f3c505f9f644b3070e.tar.bz2
slibc-37c958a639fa0c9ed2cca7f3c505f9f644b3070e.tar.xz
m bug fix
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src')
-rw-r--r--src/unistd/daemonise.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/unistd/daemonise.c b/src/unistd/daemonise.c
index 58cf848..90a9ca6 100644
--- a/src/unistd/daemonise.c
+++ b/src/unistd/daemonise.c
@@ -54,7 +54,7 @@ static char* __pidfile = NULL;
*/
static int dup_at_least_3(int old)
{
- int intermediary[] = { -1, -1, -1 };
+ int intermediary[3];
int i = 0, saved_errno;
do
@@ -67,12 +67,12 @@ static int dup_at_least_3(int old)
intermediary[i++] = old;
}
while (old < 3);
+ i--;
fail:
saved_errno = errno;
- if (intermediary[0] >= 0) close(intermediary[0]);
- if (intermediary[1] >= 0) close(intermediary[1]);
- if (intermediary[2] >= 0) close(intermediary[2]);
+ while (i--)
+ close(intermediary[i]);
errno = saved_errno;
return old;
}