summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2002-03-30 18:51:16 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2002-03-30 18:51:16 +0000
commit035d83f1ea3272b966e18af74bfbbc6db998794e (patch)
tree6070bd83d5fca33ed7dfddddd0b9a353cfe41a97 /usr.bin
parentbd9101d48251cf6d83985ffb983174516431cf09 (diff)
check waitpid for EINTR; based on patch from peter@ifm.liu.se
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/monitor.c7
-rw-r--r--usr.bin/ssh/serverloop.c16
-rw-r--r--usr.bin/ssh/sftp-int.c7
-rw-r--r--usr.bin/ssh/sftp.c8
-rw-r--r--usr.bin/ssh/sshd.c11
5 files changed, 29 insertions, 20 deletions
diff --git a/usr.bin/ssh/monitor.c b/usr.bin/ssh/monitor.c
index 737209daf36..417e6bf0ce2 100644
--- a/usr.bin/ssh/monitor.c
+++ b/usr.bin/ssh/monitor.c
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor.c,v 1.8 2002/03/27 17:45:42 mouring Exp $");
+RCSID("$OpenBSD: monitor.c,v 1.9 2002/03/30 18:51:15 markus Exp $");
#include <openssl/dh.h>
@@ -1203,8 +1203,9 @@ mm_answer_term(int socket, Buffer *req)
/* The child is terminating */
session_destroy_all(&mm_session_close);
- if (waitpid(monitor->m_pid, &status, 0) == -1)
- exit(1);
+ while (waitpid(monitor->m_pid, &status, 0) == -1)
+ if (errno != EINTR)
+ exit(1);
res = WIFEXITED(status) ? WEXITSTATUS(status) : 1;
diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c
index 93d0c30b55d..8046cd53472 100644
--- a/usr.bin/ssh/serverloop.c
+++ b/usr.bin/ssh/serverloop.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.100 2002/03/24 16:00:27 markus Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.101 2002/03/30 18:51:15 markus Exp $");
#include "xmalloc.h"
#include "packet.h"
@@ -670,10 +670,10 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
/* We no longer want our SIGCHLD handler to be called. */
signal(SIGCHLD, SIG_DFL);
- wait_pid = waitpid(-1, &wait_status, 0);
- if (wait_pid == -1)
- packet_disconnect("wait: %.100s", strerror(errno));
- else if (wait_pid != pid)
+ while ((wait_pid = waitpid(-1, &wait_status, 0)) < 0)
+ if (errno != EINTR)
+ packet_disconnect("wait: %.100s", strerror(errno));
+ if (wait_pid != pid)
error("Strange, wait returned pid %d, expected %d",
wait_pid, pid);
@@ -723,8 +723,10 @@ collect_children(void)
sigaddset(&nset, SIGCHLD);
sigprocmask(SIG_BLOCK, &nset, &oset);
if (child_terminated) {
- while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
- session_close_by_pid(pid, status);
+ while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
+ (pid < 0 && errno == EINTR))
+ if (pid > 0)
+ session_close_by_pid(pid, status);
child_terminated = 0;
}
sigprocmask(SIG_SETMASK, &oset, NULL);
diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c
index 9f22ed0454e..d4331419c9d 100644
--- a/usr.bin/ssh/sftp-int.c
+++ b/usr.bin/ssh/sftp-int.c
@@ -26,7 +26,7 @@
/* XXX: recursive operations */
#include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.45 2002/03/19 06:32:56 mpech Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.46 2002/03/30 18:51:15 markus Exp $");
#include <glob.h>
@@ -178,8 +178,9 @@ local_do_shell(const char *args)
strerror(errno));
_exit(1);
}
- if (waitpid(pid, &status, 0) == -1)
- fatal("Couldn't wait for child: %s", strerror(errno));
+ while (waitpid(pid, &status, 0) == -1)
+ if (errno != EINTR)
+ fatal("Couldn't wait for child: %s", strerror(errno));
if (!WIFEXITED(status))
error("Shell exited abormally");
else if (WEXITSTATUS(status))
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index 01c4eb013c1..5af0d72c3a8 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -24,7 +24,7 @@
#include "includes.h"
-RCSID("$OpenBSD: sftp.c,v 1.27 2002/03/19 10:49:35 markus Exp $");
+RCSID("$OpenBSD: sftp.c,v 1.28 2002/03/30 18:51:15 markus Exp $");
/* XXX: short-form remote directory listings (like 'ls -C') */
@@ -234,8 +234,10 @@ main(int argc, char **argv)
if (infile != stdin)
fclose(infile);
- if (waitpid(sshpid, NULL, 0) == -1)
- fatal("Couldn't wait for ssh process: %s", strerror(errno));
+ while (waitpid(sshpid, NULL, 0) == -1)
+ if (errno != EINTR)
+ fatal("Couldn't wait for ssh process: %s",
+ strerror(errno));
exit(0);
}
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index 88dd5b65b3c..16361eebbe6 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -42,7 +42,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.238 2002/03/23 20:57:26 stevesk Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.239 2002/03/30 18:51:15 markus Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -267,10 +267,12 @@ sigterm_handler(int sig)
static void
main_sigchld_handler(int sig)
{
+ pid_t pid;
int save_errno = errno;
int status;
- while (waitpid(-1, &status, WNOHANG) > 0)
+ while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
+ (pid < 0 && errno == EINTR))
;
signal(SIGCHLD, main_sigchld_handler);
@@ -568,8 +570,9 @@ privsep_preauth(void)
monitor_sync(monitor);
/* Wait for the child's exit status */
- waitpid(pid, &status, 0);
-
+ while (waitpid(pid, &status, 0) < 0)
+ if (errno != EINTR)
+ break;
return (authctxt);
} else {
/* child */