From 91fef437949c915b8666265b737f41263eda22bd Mon Sep 17 00:00:00 2001 From: in2 Date: Fri, 28 Mar 2003 14:15:20 +0000 Subject: PRE_FORK git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@741 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/mbbsd.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mbbsd/mbbsd.c') diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 00e4fa7a..97ba847a 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1,4 +1,4 @@ -/* $Id: mbbsd.c,v 1.68 2003/03/24 10:28:24 in2 Exp $ */ +/* $Id: mbbsd.c,v 1.69 2003/03/28 14:15:20 in2 Exp $ */ #include "bbs.h" #define SOCKET_QLEN 4 @@ -1256,7 +1256,18 @@ daemon_login(int argc, char *argv[], char *envp[]) setuid(BBSUID); chdir(BBSHOME); - snprintf(buf, sizeof(buf), "run/mbbsd.%d.pid", listen_port); +#ifndef NO_FORK +#ifdef PRE_FORK + if( listen_port == 23 ){ // only pre-fork in port 23 + int i; + for( i = 0 ; i < PRE_FORK ; ++i ) + if( fork() <= 0 ) + break; + } +#endif +#endif + + snprintf(buf, sizeof(buf), "run/mbbsd.%d.%d.pid", listen_port, getpid()); if ((fp = fopen(buf, "w"))) { fprintf(fp, "%d\n", getpid()); fclose(fp); -- cgit v1.2.3