| 21 |
#include "fork.h" |
#include "fork.h" |
| 22 |
#include <stdio.h> |
#include <stdio.h> |
| 23 |
#include <string.h> |
#include <string.h> |
| 24 |
|
#include <signal.h> |
| 25 |
#include <unistd.h> |
#include <unistd.h> |
| 26 |
#include <stdlib.h> |
#include <stdlib.h> |
| 27 |
|
#include <errno.h> |
| 28 |
|
|
| 29 |
int fork_server() |
int fork_server() |
| 30 |
{ |
{ |
| 40 |
} |
} |
| 41 |
else if (pid < 0) // Error |
else if (pid < 0) // Error |
| 42 |
{ |
{ |
| 43 |
|
log_error("fork() error (%d)\n", errno); |
| 44 |
return -1; |
return -1; |
| 45 |
} |
} |
| 46 |
|
|
| 67 |
return -4; |
return -4; |
| 68 |
} |
} |
| 69 |
|
|
| 70 |
|
SYS_child_process_count = 0; |
| 71 |
|
|
| 72 |
|
// Reset signal handler to default |
| 73 |
|
signal(SIGHUP, SIG_DFL); |
| 74 |
|
signal(SIGCHLD, SIG_DFL); |
| 75 |
|
signal(SIGTERM, SIG_DFL); |
| 76 |
|
|
| 77 |
bbs_main(); |
bbs_main(); |
| 78 |
|
|
| 79 |
|
// Child process exit |
| 80 |
|
SYS_server_exit = 1; |
| 81 |
|
|
| 82 |
if (close(socket_client) == -1) |
if (close(socket_client) == -1) |
| 83 |
{ |
{ |
| 84 |
log_error("Close client socket failed\n"); |
log_error("Close client socket failed\n"); |
| 92 |
|
|
| 93 |
log_end(); |
log_end(); |
| 94 |
|
|
|
// Exit child process normally |
|
|
exit(0); |
|
|
|
|
| 95 |
return 0; |
return 0; |
| 96 |
} |
} |