Welcome, Guest! Log In | Create Account

Changeset 113

Show
Ignore:
Timestamp:
10/19/09 08:24:25 (2 months ago)
Author:
wimpunk
Message:

Added foreground patch (1893144) submitted by John Palkovic

Location:
trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ddclient

    r112 r113  
    310310    'global-defaults'    => { 
    311311        'daemon'              => setv(T_DELAY, 0, 0, 1, 0,                    interval('60s')), 
     312        'foreground'          => setv(T_BOOL,  0, 0, 1, 0,                    undef), 
    312313        'file'                => setv(T_FILE,  0, 0, 1, "$etc$program.conf",  undef), 
    313314        'cache'               => setv(T_FILE,  0, 0, 1, "$cachedir$program.cache", undef), 
     
    549550    "options are:", 
    550551    [ "daemon",      "=s", "-daemon delay         : run as a daemon, specify delay as an interval." ], 
     552+     [ "foreground",  "!",  "-foreground           : do not fork" ], 
    551553    [ "proxy",       "=s", "-proxy host           : use 'host' as the HTTP proxy" ], 
    552554    [ "server",      "=s", "-server host          : update DNS information on 'host'" ], 
     
    637639$SIG{'TERM'}   = sub { $caught_term = 1; }; 
    638640$SIG{'KILL'}   = sub { $caught_kill = 1; }; 
    639 if (opt('daemon') && !opt('force')) { 
     641# don't fork() if foreground or force is on 
     642if (opt('foreground') || opt('force')) { 
     643    ; 
     644} elsif (opt('daemon')) { 
    640645    $SIG{'CHLD'}   = 'IGNORE'; 
    641646    my $pid = fork; 
     
    647652    } 
    648653    $SIG{'CHLD'}   = 'DEFAULT'; 
    649     $opt{'syslog'} = 1; 
    650654    open(STDOUT, ">/dev/null"); 
    651655    open(STDERR, ">/dev/null"); 
    652656    open(STDIN,  "</dev/null"); 
    653  
     657} 
     658 
     659# write out the pid file if we're daemon'ized 
     660if(opt('daemon')) {  
    654661    write_pid(); 
     662    $opt{'syslog'} = 1; 
    655663} 
    656664