| 15 |
* * |
* * |
| 16 |
***************************************************************************/ |
***************************************************************************/ |
| 17 |
|
|
| 18 |
|
#include "init.h" |
| 19 |
|
#include "database.h" |
| 20 |
#include "bbs.h" |
#include "bbs.h" |
| 21 |
#include "common.h" |
#include "common.h" |
| 22 |
|
#include "log.h" |
| 23 |
#include "io.h" |
#include "io.h" |
| 24 |
|
#include <string.h> |
| 25 |
|
#include <stdlib.h> |
| 26 |
#include <signal.h> |
#include <signal.h> |
| 27 |
#include <sys/param.h> |
#include <sys/param.h> |
| 28 |
#include <sys/types.h> |
#include <sys/types.h> |
| 32 |
void init_daemon(void) |
void init_daemon(void) |
| 33 |
{ |
{ |
| 34 |
int pid; |
int pid; |
|
int i; |
|
| 35 |
|
|
| 36 |
if (pid = fork()) |
pid = fork(); |
| 37 |
|
|
| 38 |
|
if (pid > 0) // Parent process |
| 39 |
|
{ |
| 40 |
exit(0); |
exit(0); |
| 41 |
else if (pid < 0) |
} |
| 42 |
|
else if (pid < 0) // Error |
| 43 |
|
{ |
| 44 |
exit(1); |
exit(1); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
// Child process |
| 48 |
setsid(); |
setsid(); |
| 49 |
|
|
| 50 |
if (pid = fork()) |
pid = fork(); |
| 51 |
|
|
| 52 |
|
if (pid > 0) // Parent process |
| 53 |
|
{ |
| 54 |
exit(0); |
exit(0); |
| 55 |
else if (pid < 0) |
} |
| 56 |
|
else if (pid < 0) // Error |
| 57 |
|
{ |
| 58 |
exit(1); |
exit(1); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
umask(0); |
// Child process |
| 62 |
|
umask(022); |
| 63 |
|
|
| 64 |
return; |
return; |
| 65 |
} |
} |
| 118 |
{ |
{ |
| 119 |
int y = 0, m = 0, d = 0; |
int y = 0, m = 0, d = 0; |
| 120 |
fscanf(fin, "%d-%d-%d", &y, &m, &d); |
fscanf(fin, "%d-%d-%d", &y, &m, &d); |
| 121 |
sprintf(BBS_start_dt, "%4d年%2d月%2d日", y, m, d); |
snprintf(BBS_start_dt, sizeof(BBS_start_dt), "%4d年%2d月%2d日", y, m, d); |
| 122 |
} |
} |
| 123 |
if (strcmp(c_name, "db_host") == 0) |
if (strcmp(c_name, "db_host") == 0) |
| 124 |
{ |
{ |