[Ddclient-forum] [ ddclient-Patches-1893144 ] Foreground patch
Brought to you by:
supersandro2000,
wimpunk
From: SourceForge.net <no...@so...> - 2009-10-19 08:39:03
|
Patches item #1893144, was opened at 2008-02-13 22:18 Message generated for change (Settings changed) made by wimpunk You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=676130&aid=1893144&group_id=116817 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: John Palkovic (drjohnny) Assigned to: wimpunk (wimpunk) Summary: Foreground patch Initial Comment: I am running ddclient as a dyndns.org client on a debian etch system. I had some problems with the startup script in the debian package. It was also out of date with no ssl support. I decided to patch ddclient to run under the control of runit (http://smarden.org/runit), a unix service supervisor akin to svscan (http://cr.yp.to/daemontools/svscan.html). I created the patch and have been running with it for a week with no issues to report. The patch adds a -foreground argument. When called with this argument, ddclient runs as a daemon but does not fork(). This is appropriate for use with runit or svscan (or launchd on a darwin system). There are changes to the daemon logic, so I would appreciate any comments. I will attach the patch with the upload button. -John Palkovic 13 Feb 2008 ---------------------------------------------------------------------- Comment By: wimpunk (wimpunk) Date: 2009-10-19 08:25 Message: it took me a while but your patch has been added as r113: Added foreground patch (1893144) submitted by John Palkovic ---------------------------------------------------------------------- Comment By: Sam Homer (shmlchr) Date: 2009-08-18 10:17 Message: Seems that only the person who originated an artifact is able to post attachments. In another artifact that I have opened myself, I can add attachments easily. No problem, here we go: http://ddclient.pastebin.ca/1533623 Would be great if this made it into some future version; right now 3.8.0 works just fine for me though. Thanks for a great product and for still taking good care of it. ---------------------------------------------------------------------- Comment By: wimpunk (wimpunk) Date: 2009-08-18 05:44 Message: It's a little strange you can't attach a file but as a work around, could you send me the patch or post it to http://ddclient.pastbin.ca and put a link to it here. I'll attach it here and take a second look to apply it to ddclient official release. ---------------------------------------------------------------------- Comment By: Sam Homer (shmlchr) Date: 2009-08-17 20:37 Message: Well, seems I cannot attach anything here, so here goes the patch against 3.8.0: --- ddclient-3.8.0 2009-01-27 20:14:02.000000000 +0100 +++ ddclient+foreground-3.8.0 2009-08-17 22:27:32.000000000 +0200 @@ -307,6 +307,7 @@ my %variables = ( 'global-defaults' => { 'daemon' => setv(T_DELAY, 0, 0, 1, 0, interval('60s')), + 'foreground' => setv(T_BOOL, 0, 0, 1, 0, undef), 'file' => setv(T_FILE, 0, 0, 1, "$etc$program.conf", undef), 'cache' => setv(T_FILE, 0, 0, 1, "$cachedir$program.cache", undef), 'pid' => setv(T_FILE, 0, 0, 1, "", undef), @@ -535,6 +536,7 @@ "usage: ${program} [options]", "options are:", [ "daemon", "=s", "-daemon delay : run as a daemon, specify delay as an interval." ], ++ [ "foreground", "!", "-foreground : do not fork" ], [ "proxy", "=s", "-proxy host : use 'host' as the HTTP proxy" ], [ "server", "=s", "-server host : update DNS information on 'host'" ], [ "protocol", "=s", "-protocol type : update protocol used" ], @@ -623,7 +625,10 @@ $SIG{'HUP'} = sub { $caught_hup = 1; }; $SIG{'TERM'} = sub { $caught_term = 1; }; $SIG{'KILL'} = sub { $caught_kill = 1; }; -if (opt('daemon') && !opt('force')) { +# don't fork() if foreground or force is on +if (opt('foreground') || opt('force')) { + ; +} elsif (opt('daemon')) { $SIG{'CHLD'} = 'IGNORE'; my $pid = fork; if ($pid < 0) { @@ -633,12 +638,15 @@ exit 0; } $SIG{'CHLD'} = 'DEFAULT'; - $opt{'syslog'} = 1; open(STDOUT, ">/dev/null"); open(STDERR, ">/dev/null"); open(STDIN, "</dev/null"); +} +# write out the pid file if we're daemon'ized +if(opt('daemon')) { write_pid(); + $opt{'syslog'} = 1; } umask 077; ---------------------------------------------------------------------- Comment By: Sam Homer (shmlchr) Date: 2009-08-17 20:30 Message: Thanks a lot drjohnny. I'm using your patch on Mac OS X 10.5.8 with launchd. I have attached the same patch applied against 3.8.0. All credit goes to drjohnny, mistakes are mine. ---------------------------------------------------------------------- Comment By: wimpunk (wimpunk) Date: 2008-02-18 08:28 Message: Logged In: YES user_id=722282 Originator: NO You're correct, I've made a mistake. Your patch could also be useful for debugging so I think I'll take closer look and maybe it will get included in the next release of ddclient. ---------------------------------------------------------------------- Comment By: John Palkovic (drjohnny) Date: 2008-02-14 00:02 Message: Logged In: YES user_id=985118 Originator: YES You are mistaken. fork() cannot be called, nor can exit() be reached to run properly under the control of runit or svscan. I want behavior like (apache2) httpd -DFOREGROUND or cron -f. ddclient -daemon=0 is not a daemon, it exits quickly on my debian etch box: # date Wed Feb 13 17:45:42 CST 2008 # time ddclient -daemon=0 -file /etc/ddclient.conf real 0m0.392s user 0m0.280s sys 0m0.036s This behavior is obvious if one glances at the while() statement on line 655 of 3.7.3. I want the program to loop in the do/while beginning on line 598 of version 3.7.3 without ever having called fork(). It should not exit() unless forced to by a signal or a restart. It must not call fork(). Do you understand? I don't think this functionality is available in the stock 3.7.3. ---------------------------------------------------------------------- Comment By: wimpunk (wimpunk) Date: 2008-02-13 23:00 Message: Logged In: YES user_id=722282 Originator: NO As far as I can see, you don't need a patch, you just need the daemon=0 option. I'm also wondering why you had some startup problems with the debian package. I didn't got any report about that from other people. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=676130&aid=1893144&group_id=116817 |