Also install a signal handler, as I've noticed some zombie processes

lying around...
This commit is contained in:
angelos 2001-06-09 04:21:29 +00:00
parent bb7234388f
commit 574a6ecd2c

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-jcc_c,v 1.3 2001/06/09 04:02:20 angelos Exp $ $OpenBSD: patch-jcc_c,v 1.4 2001/06/09 04:21:29 angelos Exp $
--- jcc.c.orig Fri Oct 30 22:58:47 1998 --- jcc.c.orig Fri Oct 30 22:58:47 1998
+++ jcc.c Fri Jun 8 22:24:37 2001 +++ jcc.c Sat Jun 9 00:16:47 2001
@@ -226,7 +226,7 @@ chat(struct client_state *csp) @@ -226,7 +226,7 @@ chat(struct client_state *csp)
} }
@ -57,7 +57,22 @@ $OpenBSD: patch-jcc_c,v 1.3 2001/06/09 04:02:20 angelos Exp $
freez(eno); freez(eno);
write_socket(csp->cfd, buf, strlen(buf)); write_socket(csp->cfd, buf, strlen(buf));
return; return;
@@ -661,7 +671,7 @@ main(int argc, char *argv[]) @@ -606,6 +616,14 @@ server_thread(void *data)
}
#endif
+void
+sigcatcher(int sigraised)
+{
+ if (sigraised == SIGCHLD) {
+ waitpid(-1, NULL, WNOHANG);
+ }
+}
+
int
main(int argc, char *argv[])
{
@@ -661,7 +679,7 @@ main(int argc, char *argv[])
line_num++; line_num++;
@ -66,7 +81,7 @@ $OpenBSD: patch-jcc_c,v 1.3 2001/06/09 04:02:20 angelos Exp $
if((p = strpbrk(tmp, "#\r\n"))) *p = '\0'; if((p = strpbrk(tmp, "#\r\n"))) *p = '\0';
@@ -678,7 +688,7 @@ main(int argc, char *argv[]) @@ -678,7 +696,7 @@ main(int argc, char *argv[])
while(*p && ((*p == ' ') || (*p == '\t'))) p++; while(*p && ((*p == ' ') || (*p == '\t'))) p++;
@ -75,7 +90,7 @@ $OpenBSD: patch-jcc_c,v 1.3 2001/06/09 04:02:20 angelos Exp $
p = arg + strlen(arg) - 1; p = arg + strlen(arg) - 1;
@@ -692,98 +702,98 @@ main(int argc, char *argv[]) @@ -692,98 +710,98 @@ main(int argc, char *argv[])
savearg(cmd, arg); savearg(cmd, arg);
@ -194,7 +209,20 @@ $OpenBSD: patch-jcc_c,v 1.3 2001/06/09 04:02:20 angelos Exp $
hideConsole = 1; hideConsole = 1;
continue; continue;
} }
@@ -994,7 +1004,7 @@ main(int argc, char *argv[]) @@ -891,8 +909,12 @@ main(int argc, char *argv[])
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
+#ifdef __OpenBSD__
+ signal(SIGCHLD, sigcatcher);
+#else
signal(SIGCHLD, SIG_IGN);
#endif
+#endif
#ifdef _WIN32
{
@@ -994,7 +1016,7 @@ main(int argc, char *argv[])
fprintf(logfp, "%s: can't fork: ", prog); fprintf(logfp, "%s: can't fork: ", prog);
fperror(logfp, ""); fperror(logfp, "");
@ -203,7 +231,7 @@ $OpenBSD: patch-jcc_c,v 1.3 2001/06/09 04:02:20 angelos Exp $
prog, errno); prog, errno);
write_socket(csp->cfd, buf, strlen(buf)); write_socket(csp->cfd, buf, strlen(buf));
@@ -1043,7 +1053,7 @@ safe_strerror(int err) @@ -1043,7 +1065,7 @@ safe_strerror(int err)
#endif /* NOSTRERROR */ #endif /* NOSTRERROR */
if(s == NULL) { if(s == NULL) {