/lib/init/init-d-script: exit 0 at end of script prevents all other exit codes

Petter Reinholdtsen pere at hungry.com
Thu Nov 15 07:01:44 GMT 2018

Hi Brenda,

[Benda Xu]
> Do you think init-d-script unconditionally returning 0 is a typo?
> Should it be `exit $?` instead?

Not quite sure, but as far as I know, the init.d scripts do not have a
standard for exit codes.  There is no use of exit codes from init.d
scripts in /etc/init.d/rc.  Error handling and reporting during start
and stop is supposed to take place within the init.d script itself, not
passed on to the caller as an exit code.

With that background, it is no reason not to always return 0 unless
incorrect arguments are used on the command line.

As /etc/init.d/rc is not running with 'set -e', it do not really matter
if the scripts exit with an error code.

Happy hacking
Petter Reinholdtsen

More information about the Debian-init-diversity mailing list