summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2000-08-10 21:51:50 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2000-08-10 21:51:50 (GMT)
commit8d4ec6634014aa8a88616e5d01e85ca23d3d133c (patch)
tree76a10e637567ded0d1ad025d0bcec064c1b3cb04
parentd1e9518ce3cf7867a7773908da368bde66f8bad9 (diff)
downloadautofs3-8d4ec6634014aa8a88616e5d01e85ca23d3d133c.zip
autofs3-8d4ec6634014aa8a88616e5d01e85ca23d3d133c.tar.gz
autofs3-8d4ec6634014aa8a88616e5d01e85ca23d3d133c.tar.bz2
autofs3-8d4ec6634014aa8a88616e5d01e85ca23d3d133c.tar.xz
Fix a race condition involving errno and SIGCHLD.
-rw-r--r--NEWS1
-rw-r--r--daemon/automount.c10
2 files changed, 9 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 227d1b5..f103aaa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
Since autofs-3.1.5:
-------------------
* Add a lookup method for LDAP (from Nalin Dahyabhai).
+* Fix small race condition involving errno and SIGCHLD.
Since autofs-3.1.4:
-------------------
diff --git a/daemon/automount.c b/daemon/automount.c
index 35b53ea..5a2b97e 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -3,7 +3,7 @@
*
* automount.c - Linux automounter daemon
*
- * Copyright 1997 Transmeta Corporation - All Rights Reserved
+ * Copyright 1997-2000 Transmeta Corporation - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -464,9 +464,13 @@ static int handle_packet(void)
static void sig_child(int sig)
{
pid_t pid;
- int status;
+ int status, old_errno;
volatile struct pending_mount *mt, * volatile *mtp;
+ /* We have to preserve errno, since we could have gotten
+ SIGCHLD between a system call and reading errno. */
+ old_errno = errno;
+
while ( (pid = waitpid(-1, &status, WNOHANG)) > 0 ) {
if ( pid == ap.exp_process ) {
ap.exp_process = 0;
@@ -492,6 +496,8 @@ static void sig_child(int sig)
}
}
}
+
+ errno = old_errno;
}
static void become_daemon(void)