Commit 9c323b79 9c323b7980a2cdf759c043c2bfc224f72db46974 by Sean 'Shaleh' Perry

added sigchld handling

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