Date: Wed, 16 Nov 2005 16:02:36 +0300 From: Yar Tikhiy <yar@comp.chem.msu.su> To: freebsd-rc@freebsd.org Subject: exit in rc.subr Message-ID: <20051116130236.GC35168@comp.chem.msu.su>
next in thread | raw e-mail | index | archive | help
Hi there, There are a few calls to "exit" in rc.subr, which creates problems for rc.d script writers. As a rule, library functions shouldn't exit, it's up to the caller to decide whether to exit or keep running. Any objections to the below patch? It's by sem@ with minor additions by me. Thanks. --- //depot/user/yar/hack/etc/rc.subr 2005/10/31 13:30:04 +++ //depot/user/yar/hack/etc/rc.subr 2005/11/16 10:56:56 @@ -598,12 +598,12 @@ start) if [ -z "$rc_fast" -a -n "$rc_pid" ]; then echo "${name} already running? (pid=$rc_pid)." - exit 1 + return 1 fi if [ ! -x ${_chroot}${command} ]; then info "run_rc_command: cannot run ($command)." - return 0 + return 1 fi # check for required variables, @@ -681,14 +681,14 @@ stop) if [ -z "$rc_pid" ]; then - [ -n "$rc_fast" ] && exit 0 + [ -n "$rc_fast" ] && return 0 if [ -n "$pidfile" ]; then echo \ "${name} not running? (check $pidfile)." else echo "${name} not running?" fi - exit 1 + return 1 fi # if the precmd failed and force @@ -733,7 +733,7 @@ else echo "${name} not running?" fi - exit 1 + return 1 fi echo "Reloading ${name} config files." if [ -n "$_precmd" ]; then @@ -807,7 +807,7 @@ echo 1>&2 "$0: unknown directive '$rc_arg'." rc_usage $_keywords - exit 1 + # not reached } #
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051116130236.GC35168>