exit in rc.subr

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

exit in rc.subr

Yar Tikhiy-2
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
 }
 
 #


_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"