Changeset 2aa05d4ff7651db8e132f49e6248b0f29a88bffa

Show
Ignore:
Timestamp:
04/22/12 14:26:59 (3 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1335104819 -0400
git-parent:

[658ca094d9985caeb69da119a4a9ebc6f063e8b7]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1335104819 -0400
Message:

Add support for -D -D which will foreground the parent, but still fork and manage the child. Mainly for debugging dysfunctional parent-child relationships.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_main.c

    r86e0c6a r2aa05d4  
    215215  } 
    216216 
    217   if(foreground) return passed_child_main(); 
     217  if(foreground == 1) return passed_child_main(); 
    218218 
    219219  watchdog_timeout_str = getenv("WATCHDOG_TIMEOUT"); 
     
    224224  } 
    225225 
    226   /* This isn't inherited across forks... */ 
    227   if(lockfd >= 0) noit_lockfile_release(lockfd); 
    228  
    229   fd = open("/dev/null", O_RDWR); 
    230   dup2(fd, STDIN_FILENO); 
    231   dup2(fd, STDOUT_FILENO); 
    232   dup2(fd, STDERR_FILENO); 
    233   if(fork()) exit(0); 
    234   setsid(); 
    235   if(fork()) exit(0); 
    236  
    237   /* Reacquire the lock */ 
    238   if(*lockfile) { 
    239     if(noit_lockfile_acquire(lockfile) < 0) { 
    240       noitL(noit_stderr, "Failed to acquire lock: %s\n", lockfile); 
    241       exit(-1); 
     226  if(foreground < 1) { 
     227    /* This isn't inherited across forks... */ 
     228    if(lockfd >= 0) noit_lockfile_release(lockfd); 
     229 
     230    fd = open("/dev/null", O_RDWR); 
     231    dup2(fd, STDIN_FILENO); 
     232    dup2(fd, STDOUT_FILENO); 
     233    dup2(fd, STDERR_FILENO); 
     234    if(fork()) exit(0); 
     235    setsid(); 
     236    if(fork()) exit(0); 
     237 
     238    /* Reacquire the lock */ 
     239    if(*lockfile) { 
     240      if(noit_lockfile_acquire(lockfile) < 0) { 
     241        noitL(noit_stderr, "Failed to acquire lock: %s\n", lockfile); 
     242        exit(-1); 
     243      } 
    242244    } 
    243245  } 
  • src/noitd.c

    r6e0e4eb r2aa05d4  
    121121        break; 
    122122      case 'D': 
    123         foreground = 1
     123        foreground++
    124124        break; 
    125125      case 'd': 
  • src/stratcond.c

    r87c5db7 r2aa05d4  
    124124        break; 
    125125      case 'D': 
    126         foreground = 1
     126        foreground++
    127127        break; 
    128128      default: