/[cvs]/eggdrop1.9/src/main.c
ViewVC logotype

Annotation of /eggdrop1.9/src/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.170 - (hide annotations) (download) (as text)
Sat Jun 19 18:07:01 2004 UTC (15 years, 1 month ago) by wingman
Branch: MAIN
Changes since 1.169: +49 -12 lines
File MIME type: text/x-chdr
* Added new (debugging) command: .binds
* Added "framework" for init/shutdown/restart. We should really try to avoid
  use of exit system call. More cleanups to come later.

1 wcc 1.156 /* main.c
2 guppy 1.56 *
3     * Copyright (C) 1997 Robey Pointer
4 wcc 1.153 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eggheads Development Team
5 guppy 1.56 *
6 fabian 1.14 * This program is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (at your option) any later version.
10 guppy 1.56 *
11 segfault 1.1 * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15 guppy 1.56 *
16 segfault 1.1 * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 fabian 1.14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19     */
20 tothwolf 1.117
21     #ifndef lint
22 wingman 1.170 static const char rcsid[] = "$Id: main.c,v 1.169 2004/06/17 13:32:44 wingman Exp $";
23 wcc 1.156 #endif
24    
25     #if HAVE_CONFIG_H
26     # include <config.h>
27 tothwolf 1.117 #endif
28 segfault 1.1
29 wcc 1.158 #include <eggdrop/eggdrop.h>
30 stdarg 1.151 #include <ctype.h>
31 stdarg 1.145 #include <unistd.h>
32 wcc 1.156 #include <fcntl.h>
33 wcc 1.158 #include <string.h>
34     #include <stdlib.h>
35     #include <sys/stat.h>
36     #include <errno.h>
37     #include <signal.h>
38     #include <netdb.h>
39     #include <setjmp.h>
40     #include <locale.h>
41     #include <ctype.h>
42     #include <ltdl.h>
43 wcc 1.154
44 wcc 1.161 #include <eggdrop/stat.h>
45    
46 wcc 1.129 #ifdef TIME_WITH_SYS_TIME
47     # include <sys/time.h>
48     # include <time.h>
49 wcc 1.154 #else
50     # ifdef HAVE_SYS_TIME_H
51     # include <sys/time.h>
52     # else
53     # include <time.h>
54     # endif
55 wcc 1.129 #endif
56 wcc 1.154
57 wcc 1.158 #include "lib/compat/compat.h"
58     #include "debug.h"
59     #include "core_config.h"
60 wingman 1.167 #include "core_party.h"
61 wcc 1.158 #include "core_binds.h"
62     #include "logfile.h"
63 wingman 1.167 #include "bg.h"
64     #include "main.h"
65 ite 1.76
66 wcc 1.154 #ifdef STOP_UAC /* OSF/1 complains a lot */
67     # include <sys/sysinfo.h>
68     # define UAC_NOPRINT 0x00000001 /* Don't report unaligned fixups */
69 segfault 1.1 #endif
70 drummer 1.71
71 poptix 1.62 #ifdef CYGWIN_HACKS
72 wcc 1.154 # include <windows.h>
73 poptix 1.62 #endif
74    
75 segfault 1.1 #ifndef _POSIX_SOURCE
76 wcc 1.154 # define _POSIX_SOURCE 1 /* Solaris needs this */
77 segfault 1.1 #endif
78    
79 wingman 1.170 int running = 1; /* The most important variable ever! */
80 wcc 1.154 int backgrd = 1; /* Run in the background? */
81     int make_userfile = 0; /* Start bot in make-userfile mode? */
82    
83 stdarg 1.166 const char *configfile = NULL; /* Name of the config file */
84     char pid_file[512]; /* Name of Eggdrop's pid file */
85 wcc 1.154
86     time_t online_since; /* Time the bot was started */
87     time_t now; /* Current time */
88     egg_timeval_t egg_timeval_now; /* Current time in seconds and microseconds. */
89 segfault 1.1
90 wcc 1.154 int use_stderr = 1; /* Send stuff to stderr instead of logfiles? */
91 ite 1.109
92 wcc 1.155 char version[81];
93    
94 wcc 1.154 static int lastmin = 99;
95     static struct tm nowtm;
96    
97     void core_config_init();
98 fabian 1.27
99 fabian 1.44 void fatal(const char *s, int recoverable)
100 segfault 1.1 {
101 wcc 1.160 putlog(LOG_MISC, "*", "Fatal: %s", s);
102 wcc 1.154 flushlogs();
103     unlink(pid_file);
104     if (!recoverable) {
105     bg_send_quit(BG_ABORT);
106     exit(1);
107     }
108 segfault 1.1 }
109    
110     static void got_bus(int z)
111     {
112 wcc 1.160 fatal("BUS ERROR.", 1);
113 segfault 1.1 #ifdef SA_RESETHAND
114 wcc 1.154 kill(getpid(), SIGBUS);
115 segfault 1.1 #else
116 wcc 1.154 bg_send_quit(BG_ABORT);
117     exit(1);
118 segfault 1.1 #endif
119     }
120    
121     static void got_segv(int z)
122     {
123 wcc 1.160 fatal("SEGMENT VIOLATION.", 1);
124 segfault 1.1 #ifdef SA_RESETHAND
125 wcc 1.154 kill(getpid(), SIGSEGV);
126 segfault 1.1 #else
127 wcc 1.154 bg_send_quit(BG_ABORT);
128     exit(1);
129 segfault 1.1 #endif
130     }
131    
132     static void got_fpe(int z)
133     {
134 wcc 1.160 fatal("FLOATING POINT ERROR.", 0);
135 segfault 1.1 }
136    
137     static void got_term(int z)
138     {
139 wcc 1.154 eggdrop_event("sigterm");
140     if (core_config.die_on_sigterm) {
141 wcc 1.157 putlog(LOG_MISC, "*", _("Saving user file..."));
142 wcc 1.154 user_save(core_config.userfile);
143 wcc 1.157 putlog(LOG_MISC, "*", _("Saving config file..."));
144 wcc 1.154 core_config_save();
145 wcc 1.157 putlog(LOG_MISC, "*", _("Bot shutting down: received TERMINATE signal."));
146 wcc 1.154 flushlogs();
147     unlink(pid_file);
148     exit(0);
149     }
150 wcc 1.157 else putlog(LOG_MISC, "*", _("Received TERMINATE signal (ignoring)."));
151 segfault 1.1 }
152    
153     static void got_quit(int z)
154     {
155 wcc 1.154 eggdrop_event("sigquit");
156 wcc 1.157 putlog(LOG_MISC, "*", _("Received QUIT signal (ignoring)."));
157 wcc 1.154 return;
158 segfault 1.1 }
159    
160     static void got_hup(int z)
161     {
162 wcc 1.154 eggdrop_event("sighup");
163 wcc 1.157 putlog(LOG_MISC, "*", _("Received HUP signal (ignoring)."));
164 wcc 1.154 return;
165 segfault 1.1 }
166    
167 wingman 1.168 #if 0
168 segfault 1.1 static void got_ill(int z)
169     {
170 wcc 1.154 eggdrop_event("sigill");
171 wcc 1.157 putlog(LOG_MISC, "*", _("Received ILL signal (ignoring)."));
172 fabian 1.10 }
173 wingman 1.168 #endif
174 fabian 1.10
175 ite 1.114
176 wcc 1.135 static void print_version(void)
177 segfault 1.1 {
178 wcc 1.154 printf("%s\n", version);
179 ite 1.114 }
180    
181 wcc 1.163 static void print_help(char *const *argv)
182 wcc 1.154 {
183     print_version();
184 wcc 1.157 printf(_("\nUsage: %s [OPTIONS]... [FILE]\n"), argv[0]);
185 wcc 1.154 printf(_("\n\
186 ite 1.114 -h, --help Print help and exit\n\
187     -v, --version Print version and exit\n\
188     -n, --foreground Don't go into the background (default=off)\n\
189     -c --channel-stats (with -n) Display channel stats every 10 seconds\n\
190     -t --terminal (with -n) Use terminal to simulate dcc-chat\n\
191     -m --make-userfile Userfile creation mode\n\
192 wcc 1.135 FILE optional config filename (default 'config.xml')\n"));
193 wcc 1.154 printf("\n");
194 ite 1.114 }
195 segfault 1.1
196 wcc 1.156 static void do_args(int argc, char *const *argv)
197 ite 1.114 {
198 wcc 1.154 int c;
199 ite 1.114
200 wcc 1.154 optarg = 0;
201     optind = 1;
202     opterr = 1;
203     optopt = '?';
204 ite 1.114
205 wcc 1.154 while (1) {
206     int option_index = 0;
207 ite 1.114
208 wcc 1.154 static struct option long_options[] = {
209     {"help", 0, NULL, 'h'},
210     {"version", 0, NULL, 'v'},
211     {"load-module", 1, NULL, 'p'},
212     {"foreground", 0, NULL, 'n'},
213     {"terminal", 0, NULL, 't'},
214     {"make-userfile", 0, NULL, 'm'},
215     {NULL, 0, NULL, 0}
216     };
217    
218     c = getopt_long(argc, argv, "hvp:nctm", long_options, &option_index);
219     if (c == -1) break;
220     switch (c) {
221     case 'n':
222     backgrd = 0;
223     break;
224     case 't':
225 wingman 1.168 partyline_terminal_mode = 1;
226 wcc 1.154 break;
227     case 'm':
228     make_userfile = 1;
229     break;
230     case 'v':
231     print_version();
232     bg_send_quit(BG_ABORT);
233     exit(0);
234     break; /* this should never be reached */
235     case 'h':
236     print_help(argv);
237     bg_send_quit(BG_ABORT);
238     exit(0);
239     break; /* this should never be reached */
240     case 0: /* Long option with no short option */
241     case '?': /* Invalid option. */
242     /* getopt_long() already printed an error message. */
243     bg_send_quit(BG_ABORT);
244     exit(1);
245     default: /* bug: option not considered. */
246 wcc 1.157 fprintf(stderr, _("%s: option unknown: %c\n"), argv[0], c);
247 wcc 1.154 bg_send_quit(BG_ABORT);
248     exit(1);
249     break; /* this should never be reached */
250     }
251     }
252 stdarg 1.166 if (optind < argc) configfile = argv[optind];
253     else configfile = "config.xml";
254 segfault 1.1 }
255    
256 fabian 1.34 /* Called once a second.
257 fabian 1.27 */
258 stdarg 1.139 static int core_secondly()
259 segfault 1.1 {
260 wcc 1.154 static int cnt = 0;
261     int miltime;
262 segfault 1.1
263 wcc 1.154 check_bind_secondly();
264     cnt++;
265     memcpy(&nowtm, localtime(&now), sizeof(struct tm));
266     if (nowtm.tm_min != lastmin) {
267     int i = 0;
268    
269     /* Once a minute */
270     lastmin = (lastmin + 1) % 60;
271     eggdrop_event("minutely");
272     check_bind_time(&nowtm);
273     /* In case for some reason more than 1 min has passed: */
274     while (nowtm.tm_min != lastmin) {
275     /* Timer drift, dammit */
276     putlog(LOG_DEBUG, "*", "timer: drift (lastmin=%d, now=%d)", lastmin, nowtm.tm_min);
277     i++;
278     lastmin = (lastmin + 1) % 60;
279     eggdrop_event("minutely");
280     }
281 wcc 1.157 if (i > 1) putlog(LOG_MISC, "*", _("Warning: timer drift (%d minutes)."), i);
282 segfault 1.1
283 wcc 1.154 miltime = (nowtm.tm_hour * 100) + (nowtm.tm_min);
284     if (((int) (nowtm.tm_min / 5) * 5) == (nowtm.tm_min)) { /* 5 minutes */
285     eggdrop_event("5minutely");
286     if (!miltime) { /* At midnight */
287     char s[25];
288    
289     strlcpy(s, ctime(&now), sizeof s);
290     putlog(LOG_ALL, "*", "--- %.11s%s", s, s + 20);
291     eggdrop_event("backup");
292     eggdrop_event("daily");
293     }
294     }
295     }
296     return(0);
297 segfault 1.1 }
298    
299 stdarg 1.140
300 stdarg 1.142 int file_check(const char *filename)
301     {
302     struct stat sbuf = {0};
303     int r;
304    
305     r = stat(filename, &sbuf);
306     if (r) return(-1);
307     errno = 0;
308     if (sbuf.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) return(-1);
309     return(0);
310     }
311    
312 segfault 1.1 int main(int argc, char **argv)
313     {
314 wcc 1.154 int xx, i, timeout;
315     char s[25], *modname, *scriptname;
316     FILE *f;
317     struct sigaction sv;
318     egg_timeval_t howlong;
319     void *config_root, *entry;
320 segfault 1.1
321 tothwolf 1.81 #ifdef DEBUG
322 wcc 1.154 {
323     # include <sys/resource.h>
324     struct rlimit cdlim;
325    
326     cdlim.rlim_cur = RLIM_INFINITY;
327     cdlim.rlim_max = RLIM_INFINITY;
328     setrlimit(RLIMIT_CORE, &cdlim);
329     }
330 fabian 1.15 #endif
331 fabian 1.32
332 ite 1.99 #ifdef ENABLE_NLS
333 wcc 1.154 setlocale(LC_MESSAGES, "");
334     bindtextdomain(PACKAGE, LOCALEDIR);
335     textdomain(PACKAGE);
336 ite 1.99 #endif
337 wcc 1.143
338 stdarg 1.145 /* Initialize ltdl. */
339     LTDL_SET_PRELOADED_SYMBOLS();
340     if (lt_dlinit()) {
341 wcc 1.160 printf("Fatal error initializing ltdl: %s\n", lt_dlerror());
342 stdarg 1.145 return(-1);
343     }
344    
345 wcc 1.154 snprintf(version, sizeof version, "Eggdrop v%s (C) 1997 Robey Pointer (C) 2004 Eggheads Development Team", VERSION);
346    
347 segfault 1.1 #ifdef STOP_UAC
348 wcc 1.154 {
349     int nvpair[2];
350 segfault 1.1
351 wcc 1.154 nvpair[0] = SSIN_UACPROC;
352     nvpair[1] = UAC_NOPRINT;
353     setsysinfo(SSI_NVPAIRS, (char *) nvpair, 1, NULL, 0);
354     }
355 segfault 1.1 #endif
356 fabian 1.27
357 wcc 1.154 sv.sa_handler = got_bus;
358     sigemptyset(&sv.sa_mask);
359 segfault 1.1 #ifdef SA_RESETHAND
360 wcc 1.154 sv.sa_flags = SA_RESETHAND;
361 segfault 1.1 #else
362 wcc 1.154 sv.sa_flags = 0;
363 segfault 1.1 #endif
364 wcc 1.154 sigaction(SIGBUS, &sv, NULL);
365    
366     sv.sa_handler = got_segv;
367     sigaction(SIGSEGV, &sv, NULL);
368 segfault 1.1 #ifdef SA_RESETHAND
369 wcc 1.154 sv.sa_flags = 0;
370 segfault 1.1 #endif
371 wcc 1.154
372     sv.sa_handler = got_fpe;
373     sigaction(SIGFPE, &sv, NULL);
374    
375     sv.sa_handler = got_term;
376     sigaction(SIGTERM, &sv, NULL);
377    
378     sv.sa_handler = got_hup;
379     sigaction(SIGHUP, &sv, NULL);
380    
381     sv.sa_handler = got_quit;
382     sigaction(SIGQUIT, &sv, NULL);
383    
384     sv.sa_handler = SIG_IGN;
385     sigaction(SIGPIPE, &sv, NULL);
386    
387 wingman 1.168 /* XXX: why is this disabled? */
388     #if 0
389     sv.sa_handler = got_ill;
390     sigaction(SIGILL, &sv, NULL);
391     #endif
392 wcc 1.154
393     timer_update_now(&egg_timeval_now);
394     now = egg_timeval_now.sec;
395     memcpy(&nowtm, localtime(&now), sizeof(struct tm));
396     lastmin = nowtm.tm_min;
397    
398     srandom(now % (getpid() + getppid()));
399    
400     do_args(argc, argv);
401     printf("\n%s\n", version);
402 wcc 1.160 printf("WARNING: Do NOT run this DEVELOPMENT version for any purpose other than testing.\n\n");
403 wcc 1.154
404 wcc 1.160 if (((int) getuid() == 0) || ((int) geteuid() == 0)) fatal("Eggdrop will not run as root!", 0);
405 stdarg 1.142
406     if (file_check(configfile)) {
407     if (errno) perror(configfile);
408 wcc 1.160 else fprintf(stderr, "ERROR\n\nCheck file permissions on your config file!\nMake sure other groups and users cannot read/write it.\n");
409 stdarg 1.142 exit(-1);
410     }
411 guppy 1.53
412 stdarg 1.151 eggdrop_init();
413     core_config_init(configfile);
414     logfile_init();
415 wingman 1.169 if (core_config.userfile)
416     user_load(core_config.userfile);
417 wingman 1.170 core_binds_init();
418 stdarg 1.151 core_party_init();
419    
420     if (make_userfile) {
421     user_t *owner;
422     char handle[512], password[12];
423     int len;
424    
425     if (user_count() != 0) {
426 wcc 1.160 printf("\n\n\nYou are trying to create a new userfile, but the old one still exists (%s)!\n\nPlease remove the userfile, or do not pass the -m option.\n\n", core_config.userfile);
427 stdarg 1.151 exit(1);
428     }
429    
430 wcc 1.160 printf("\n\n\nHello! I see you are creating a new userfile.\n\n");
431     printf("Let's create the owner account.\n\n");
432 stdarg 1.151 do {
433 wcc 1.160 printf("Enter the owner handle: ");
434 stdarg 1.151 fflush(stdout);
435     fgets(handle, sizeof(handle), stdin);
436     for (len = 0; handle[len]; len++) {
437     if (!ispunct(handle[len]) && !isalnum(handle[len])) break;
438     }
439 wcc 1.160 if (len == 0) printf("Come on, enter a real handle.\n\n");
440 stdarg 1.151 } while (len <= 0);
441     handle[len] = 0;
442     owner = user_new(handle);
443     if (!owner) {
444 wcc 1.160 printf("Failed to create user record! Out of memory?\n\n");
445 stdarg 1.151 exit(1);
446     }
447     user_rand_pass(password, sizeof(password));
448     user_set_pass(owner, password);
449 wingman 1.169 user_set_flags_str(owner, NULL, "+n");
450 wcc 1.160 printf("Your owner handle is '%s' and your password is '%s' (without the quotes).\n\n", handle, password);
451 stdarg 1.151 memset(password, 0, sizeof(password));
452     str_redup(&core_config.owner, handle);
453     core_config_save();
454     user_save(core_config.userfile);
455     }
456 stdarg 1.80
457 wcc 1.154 if (backgrd) bg_prepare_split();
458 stdarg 1.80
459 wcc 1.154 strlcpy(s, ctime(&now), sizeof s);
460     strcpy(&s[11], &s[20]);
461     putlog(LOG_ALL, "*", "Loading Eggdrop %s (%s)", VERSION, s);
462     snprintf(pid_file, sizeof pid_file, "pid.%s", core_config.botname);
463    
464     f = fopen(pid_file, "r");
465     if (f != NULL) {
466     fgets(s, 10, f);
467     xx = atoi(s);
468     kill(xx, SIGCHLD); /* Meaningless kill to determine if pid is used */
469     if (errno != ESRCH) {
470 wcc 1.160 printf("I detect %s already running from this directory.\n", core_config.botname);
471     printf("If this is incorrect, please erase '%s'.\n", pid_file);
472 wcc 1.154 bg_send_quit(BG_ABORT);
473     exit(1);
474     }
475     }
476 fabian 1.27
477 wingman 1.169 /* Load core help */
478     help_load_by_module ("core");
479    
480 stdarg 1.151 /* Put the module directory in the ltdl search path. */
481 wingman 1.169 if (core_config.module_path)
482     module_add_dir(core_config.module_path);
483 stdarg 1.151
484     /* Scan the autoload section of config. */
485     config_root = config_get_root("eggdrop");
486     for (i = 0; (entry = config_exists(config_root, "eggdrop", 0, "autoload", 0, "module", i, NULL)); i++) {
487     modname = NULL;
488     config_get_str(&modname, entry, NULL);
489     module_load(modname);
490     }
491     for (i = 0; (entry = config_exists(config_root, "eggdrop", 0, "autoload", 0, "script", i, NULL)); i++) {
492     scriptname = NULL;
493     config_get_str(&scriptname, entry, NULL);
494     script_load(scriptname);
495     }
496    
497 wcc 1.154 if (backgrd) { /* Move into background? */
498 fabian 1.38 #ifndef CYGWIN_HACKS
499 wcc 1.154 bg_do_split();
500     }
501     else {
502 fabian 1.5 #endif
503 wcc 1.154 xx = getpid();
504     if (xx != 0) {
505     FILE *fp;
506    
507     unlink(pid_file);
508     fp = fopen(pid_file, "w");
509     if (fp != NULL) {
510     fprintf(fp, "%u\n", xx);
511     if (fflush(fp)) {
512     /* Let the bot live since this doesn't appear to be a botchk */
513 wcc 1.160 printf("WARNING: Could not write pid file '%s'.\n", pid_file);
514 wcc 1.154 fclose(fp);
515     unlink(pid_file);
516     }
517     else fclose(fp);
518     }
519 wcc 1.160 else printf("WARNING: Could not write pid file '%s'.\n", pid_file);
520 fabian 1.38 #ifdef CYGWIN_HACKS
521 wcc 1.160 printf("Launched into the background (pid: %d).\n\n", xx);
522 fabian 1.38 #endif
523 wcc 1.154 }
524     }
525 stdarg 1.151
526 wcc 1.154 use_stderr = 0; /* Stop writing to stderr now */
527 fabian 1.38
528 wcc 1.154 if (backgrd) {
529     /* Try to disassociate from controlling terminal (finger cross) */
530 fabian 1.5 #if HAVE_SETPGID && !defined(CYGWIN_HACKS)
531 wcc 1.154 setpgid(0, 0);
532 segfault 1.1 #endif
533 wcc 1.154 /* Tcl wants the stdin, stdout and stderr file handles kept open. */
534     freopen("/dev/null", "r", stdin);
535     freopen("/dev/null", "w", stdout);
536     freopen("/dev/null", "w", stderr);
537 poptix 1.62 #ifdef CYGWIN_HACKS
538 wcc 1.154 FreeConsole();
539 poptix 1.62 #endif
540 wcc 1.154 }
541 fabian 1.27
542 wcc 1.154 online_since = now;
543     howlong.sec = 1;
544     howlong.usec = 0;
545     timer_create_repeater(&howlong, "main loop", core_secondly);
546 segfault 1.1
547 wcc 1.154 putlog(LOG_DEBUG, "*", "Entering main loop.");
548 wingman 1.167
549 wingman 1.170 core_init();
550 wingman 1.167
551 wingman 1.170 putlog(LOG_DEBUG, "*", "Entering main loop.");
552    
553     while (running) {
554 stdarg 1.139 timer_update_now(&egg_timeval_now);
555     now = egg_timeval_now.sec;
556     random(); /* Woop, lets really jumble things */
557     timer_run();
558 wcc 1.154 if (timer_get_shortest(&howlong)) timeout = 1000;
559     else timeout = howlong.sec * 1000 + howlong.usec / 1000;
560 stdarg 1.139 sockbuf_update_all(timeout);
561 stdarg 1.150 garbage_run();
562 stdarg 1.131 }
563 wingman 1.167
564 wingman 1.170 /* No work need to be done here ever since if we can only reach this
565     * if someone called core_shutdown. So do your shutdown work THERE! */
566    
567     return 1;
568     }
569    
570     int core_init()
571     {
572     check_bind_init();
573    
574     return 1;
575     }
576    
577     int core_shutdown(int how, const char *nick, const char *reason)
578     {
579     putlog(LOG_MISC, "*", "Shutdown requested by %s: %s", nick, (reason) ? reason : "No reason");
580    
581     /* notify that we go down NOW */
582     check_bind_shutdown();
583    
584     /* XXX: move this to users.c */
585     putlog(LOG_MISC, "*", _("Saving user file..."));
586     user_save(core_config.userfile);
587    
588     /* flush logs */
589     flushlogs();
590    
591     /* remove pid file */
592     unlink(pid_file);
593    
594     switch (how) {
595    
596     case (SHUTDOWN_GRACEFULL):
597     running = 0;
598     break;
599    
600     case (SHUTDOWN_HARD):
601     exit(0);
602     break;
603     }
604    
605     return BIND_RET_LOG;
606 segfault 1.1 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23