Commit 9c323b79 9c323b7980a2cdf759c043c2bfc224f72db46974 by Sean 'Shaleh' Perry

added sigchld handling

1 parent fdc6161f
Sean 'Shaleh' Perry <shaleh@debian.org> Tue, 5 Oct 1999 17:46:31 -0700
* added pop3d/signal.c -- contains pop3_sigchld() currently
Sean 'Shaleh' Perry <shaleh@debian.org> Mon, 4 Oct 1999 17:57:17 -0700
* initial fork() rewrite, not even compiled it yet
......
......@@ -5,11 +5,11 @@ sbin_PROGRAMS = pop3d
pop3d_DEPENDENDENCIES = ../libmailbox/libmailbox.la ../libsrc/libgetopt.la\
../libsrc/libmd5.la
pop3d_SOURCES = apop.c auth.c capa.c dele.c extra.c pop3d.c pop3d.h\
list.c noop.c quit.c retr.c rset.c stat.c top.c uidl.c user.c
list.c noop.c quit.c retr.c rset.c stat.c top.c uidl.c user.c signal.c
#if USE_LIBPAM
#pop3d_LDADD = ../libmailbox/libmailbox.la -lpam -ldl
#else
#pop3d_LDADD = ../libmailbox/libmailbox.la
#endif
pop3d_LADADD = ../libmailbox/libmailbox.la $(AUTHLIBS)
\ No newline at end of file
pop3d_LADADD = ../libmailbox/libmailbox.la $(AUTHLIBS)
......
......@@ -145,10 +145,7 @@ pop3_usage (char *argv0)
void
pop3_signal (int signal)
{
if (signal == SIGCHLD)
--children;
else
pop3_abquit (ERR_SIGNAL);
pop3_abquit (ERR_SIGNAL);
}
/* Gets a line of input from the client */
......
......@@ -18,8 +18,9 @@
#include "pop3d.h"
typedef struct sockaddr_in SA;
/* count of number of child processes */
unsigned int children = 0;
#define strorepid(foo) /* will add more code here later */
static struct option long_options[] =
{
......@@ -165,7 +166,7 @@ pop3_daemon_init (void)
for (i = 0; i < MAXFD; ++i)
close(i);
signal (SIGCHLD, pop3_signal); /* for forking */
signal (SIGCHLD, pop3_sigchld);
}
/* The main part of the daemon. This function reads input from the client and
......@@ -336,11 +337,11 @@ pop3_daemon (unsigned int maxchildren)
else if(pid == 0) /* child */
{
close(listenfd);
/* syslog(); FIXME log the info on the connectiing client */
pop3_mainloop(connfd, connfd);
}
else
{
storepid(pid);
++children;
}
......
......@@ -168,6 +168,7 @@ int pop3_mainloop (int infile, int outfile);
int pop3_daemon (int maxchildren);
void pop3_usage (char *argv0);
void pop3_signal (int signal);
void pop3_sigchld (int signal);
void pop3_daemon_init (void);
#ifdef _USE_APOP
char *pop3_apopuser (const char *user);
......
/* GNU copyright notice */
#include "pop3d.h"
void
pop3_sigchld (int signal)
{
pid_t pid;
int stat;
while ( (pid = waitpid(-1, &stat, WNOHANG)) > 0)
--children;
return;
}