Changeset 6ea1437c0c3bf66019712e69022aa85dd6314f67

Show
Ignore:
Timestamp:
08/01/08 02:49:07 (6 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
  • src/noitd.c

    r9a2ae90 r6ea1437  
    2828 
    2929static char *config_file = ETC_DIR "/" APPNAME ".conf"; 
     30static int foreground = 0; 
    3031static int debug = 0; 
    3132 
    3233void parse_clargs(int argc, char **argv) { 
    3334  int c; 
    34   while((c = getopt(argc, argv, "c:d")) != EOF) { 
     35  while((c = getopt(argc, argv, "c:dD")) != EOF) { 
    3536    switch(c) { 
    3637      case 'c': 
    3738        config_file = strdup(optarg); 
     39        break; 
     40      case 'D': 
     41        foreground = 1; 
    3842        break; 
    3943      case 'd': 
     
    9599static int watch_over_child(int (*func)()) { 
    96100  int child_pid; 
    97   setup_mmap(); 
    98101  while(1) { 
    99102    child_pid = fork(); 
     
    227230  } 
    228231 
     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 
    229240  return watch_over_child(child_main); 
    230241}