[monitor.c serverloop.c sftp-int.c sftp.c sshd.c]
     check waitpid for EINTR; based on patch from peter@ifm.liu.se
This commit is contained in:
Ben Lindstrom 2002-04-02 20:48:19 +00:00
parent 03f3932829
commit 47fd8112b5
6 changed files with 33 additions and 21 deletions

View File

@ -19,6 +19,9 @@
- stevesk@cvs.openbsd.org 2002/03/29 19:18:33 - stevesk@cvs.openbsd.org 2002/03/29 19:18:33
[auth-rsa.c ssh-rsa.c ssh.h] [auth-rsa.c ssh-rsa.c ssh.h]
make RSA modulus minimum #define; ok markus@ make RSA modulus minimum #define; ok markus@
- markus@cvs.openbsd.org 2002/03/30 18:51:15
[monitor.c serverloop.c sftp-int.c sftp.c sshd.c]
check waitpid for EINTR; based on patch from peter@ifm.liu.se
20020401 20020401
- (stevesk) [monitor.c] PAM should work again; will *not* work with - (stevesk) [monitor.c] PAM should work again; will *not* work with
@ -8126,4 +8129,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.2012 2002/04/02 20:43:11 mouring Exp $ $Id: ChangeLog,v 1.2013 2002/04/02 20:48:19 mouring Exp $

View File

@ -25,7 +25,7 @@
*/ */
#include "includes.h" #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> #include <openssl/dh.h>
@ -1211,8 +1211,9 @@ mm_answer_term(int socket, Buffer *req)
/* The child is terminating */ /* The child is terminating */
session_destroy_all(&mm_session_close); session_destroy_all(&mm_session_close);
if (waitpid(monitor->m_pid, &status, 0) == -1) while (waitpid(monitor->m_pid, &status, 0) == -1)
exit(1); if (errno != EINTR)
exit(1);
res = WIFEXITED(status) ? WEXITSTATUS(status) : 1; res = WIFEXITED(status) ? WEXITSTATUS(status) : 1;

View File

@ -35,7 +35,7 @@
*/ */
#include "includes.h" #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 "xmalloc.h"
#include "packet.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. */ /* We no longer want our SIGCHLD handler to be called. */
mysignal(SIGCHLD, SIG_DFL); mysignal(SIGCHLD, SIG_DFL);
wait_pid = waitpid(-1, &wait_status, 0); while ((wait_pid = waitpid(-1, &wait_status, 0)) < 0)
if (wait_pid == -1) if (errno != EINTR)
packet_disconnect("wait: %.100s", strerror(errno)); packet_disconnect("wait: %.100s", strerror(errno));
else if (wait_pid != pid) if (wait_pid != pid)
error("Strange, wait returned pid %d, expected %d", error("Strange, wait returned pid %d, expected %d",
wait_pid, pid); wait_pid, pid);
@ -723,8 +723,10 @@ collect_children(void)
sigaddset(&nset, SIGCHLD); sigaddset(&nset, SIGCHLD);
sigprocmask(SIG_BLOCK, &nset, &oset); sigprocmask(SIG_BLOCK, &nset, &oset);
if (child_terminated) { if (child_terminated) {
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
session_close_by_pid(pid, status); (pid < 0 && errno == EINTR))
if (pid > 0)
session_close_by_pid(pid, status);
child_terminated = 0; child_terminated = 0;
} }
sigprocmask(SIG_SETMASK, &oset, NULL); sigprocmask(SIG_SETMASK, &oset, NULL);

View File

@ -26,7 +26,7 @@
/* XXX: recursive operations */ /* XXX: recursive operations */
#include "includes.h" #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 "buffer.h" #include "buffer.h"
#include "xmalloc.h" #include "xmalloc.h"
@ -176,8 +176,9 @@ local_do_shell(const char *args)
strerror(errno)); strerror(errno));
_exit(1); _exit(1);
} }
if (waitpid(pid, &status, 0) == -1) while (waitpid(pid, &status, 0) == -1)
fatal("Couldn't wait for child: %s", strerror(errno)); if (errno != EINTR)
fatal("Couldn't wait for child: %s", strerror(errno));
if (!WIFEXITED(status)) if (!WIFEXITED(status))
error("Shell exited abormally"); error("Shell exited abormally");
else if (WEXITSTATUS(status)) else if (WEXITSTATUS(status))

8
sftp.c
View File

@ -24,7 +24,7 @@
#include "includes.h" #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') */ /* XXX: short-form remote directory listings (like 'ls -C') */
@ -246,8 +246,10 @@ main(int argc, char **argv)
if (infile != stdin) if (infile != stdin)
fclose(infile); fclose(infile);
if (waitpid(sshpid, NULL, 0) == -1) while (waitpid(sshpid, NULL, 0) == -1)
fatal("Couldn't wait for ssh process: %s", strerror(errno)); if (errno != EINTR)
fatal("Couldn't wait for ssh process: %s",
strerror(errno));
exit(0); exit(0);
} }

11
sshd.c
View File

@ -42,7 +42,7 @@
*/ */
#include "includes.h" #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/dh.h>
#include <openssl/bn.h> #include <openssl/bn.h>
@ -276,10 +276,12 @@ sigterm_handler(int sig)
static void static void
main_sigchld_handler(int sig) main_sigchld_handler(int sig)
{ {
pid_t pid;
int save_errno = errno; int save_errno = errno;
int status; int status;
while (waitpid(-1, &status, WNOHANG) > 0) while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
(pid < 0 && errno == EINTR))
; ;
signal(SIGCHLD, main_sigchld_handler); signal(SIGCHLD, main_sigchld_handler);
@ -577,8 +579,9 @@ privsep_preauth(void)
monitor_sync(monitor); monitor_sync(monitor);
/* Wait for the child's exit status */ /* Wait for the child's exit status */
waitpid(pid, &status, 0); while (waitpid(pid, &status, 0) < 0)
if (errno != EINTR)
break;
return (authctxt); return (authctxt);
} else { } else {
/* child */ /* child */