Page 1 of 1

Return value zero when aborting startup

Posted: January 10th, 2009, 5:04 pm
by jcfp
The program exits with a return value of zero despite hitting a serious problem with the log dir setting causing it to abort startup. As a result, an init script or any other program trying to start the program as a daemon will wrongly indicate a successful startup.

Offending code is here (from SABnzbd.py):

Code: Select all

    if fork and not my_logdir:
        print "Error:"
        print "I refuse to fork without a log directory!"
        sys.exit()
Should be trivial to fix.

Re: Return value zero when aborting startup

Posted: January 10th, 2009, 8:38 pm
by switch
Filed as ticket #216. Would it be useful to return an error message in the exit return code as to why sabnzbd needed to quit? (But still just 0 on a planned exit).

Re: Return value zero when aborting startup

Posted: January 11th, 2009, 5:31 am
by jcfp
switch wrote: Filed as ticket #216. Would it be useful to return an error message in the exit return code as to why sabnzbd needed to quit? (But still just 0 on a planned exit).
Thanks. The main issue is to be able to determine that this exit is not what the user intended and expected (i.e. a successful program start), thus the exit status should always be non-zero irrespective of the mode of failure. This specific condition with the log dir when forking is the only example I know of where the program doesn't do that. See jrebeiro's posts on the ubuntu repository thread for the background of this bug report.

As for passing the error message as part of the actual exit (rather than printing it separately as is): only useful for consistency if that's the way it's done all over sabnzbd already, for init scripts etc all that really matters to distinguish success from failure is the return value.