Changeset 6ea1437c0c3bf66019712e69022aa85dd6314f67
- Timestamp:
- 08/01/08 02:49:07
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1217558947 +0000
- git-parent:
[475c937dd476e8050d8b43a5e558be5cbfdf3012]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1217558947 +0000
- Message:
make a -D (don't daemonize) flag... otherwise debugging is a PITA, refs #48
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r9a2ae90 |
r6ea1437 |
|
| 28 | 28 | |
|---|
| 29 | 29 | static char *config_file = ETC_DIR "/" APPNAME ".conf"; |
|---|
| | 30 | static int foreground = 0; |
|---|
| 30 | 31 | static int debug = 0; |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | void parse_clargs(int argc, char **argv) { |
|---|
| 33 | 34 | int c; |
|---|
| 34 | | while((c = getopt(argc, argv, "c:d")) != EOF) { |
|---|
| | 35 | while((c = getopt(argc, argv, "c:dD")) != EOF) { |
|---|
| 35 | 36 | switch(c) { |
|---|
| 36 | 37 | case 'c': |
|---|
| 37 | 38 | config_file = strdup(optarg); |
|---|
| | 39 | break; |
|---|
| | 40 | case 'D': |
|---|
| | 41 | foreground = 1; |
|---|
| 38 | 42 | break; |
|---|
| 39 | 43 | case 'd': |
|---|
| … | … | |
| 95 | 99 | static int watch_over_child(int (*func)()) { |
|---|
| 96 | 100 | int child_pid; |
|---|
| 97 | | setup_mmap(); |
|---|
| 98 | 101 | while(1) { |
|---|
| 99 | 102 | child_pid = fork(); |
|---|
| … | … | |
| 227 | 230 | } |
|---|
| 228 | 231 | |
|---|
| | 232 | setup_mmap(); |
|---|
| | 233 | if(foreground) return child_main(); |
|---|
| | 234 | |
|---|
| | 235 | chdir("/"); |
|---|
| | 236 | if(fork()) exit(0); |
|---|
| | 237 | setsid(); |
|---|
| | 238 | if(fork()) exit(0); |
|---|
| | 239 | |
|---|
| 229 | 240 | return watch_over_child(child_main); |
|---|
| 230 | 241 | } |
|---|