[CentOS] Certain scripts "hang" the terminal on logout

Sean Carolan scarolan at gmail.com
Fri Oct 24 15:55:54 UTC 2008


>> # /etc/init.d/script restart  << this runs fine, returns my shell prompt
>> # exit  <<  When I enter this command, my shell window just stays
>> "stuck" and actually won't close down.
>>
>> Anyone know why this happens?
>
> Are you spawning/backgrounding jobs in the script?

Here is the script, it is a fairly simple start/stop/reset script that
was written by Jay Farschman. One other question I had about this
script is what the "$PROG" variable in the stop() function is for.

#!/bin/sh
#
# swatchrc      This shell script takes care of starting and stopping
#               swatch.
#
# chkconfig: 2345 81 31
# description: Swatch is a System WATCHdog program that we are
#              using here to block repeated failed ssh logins.
# processname: swatch

# Replace --tail-file with the file you wish to watch, see /etc/swatch/swatchrc

RETVAL=0
test -x /usr/bin/swatch || exit 0
start(){
  echo "Starting swatch"
    # Spawn a new swatch program
      /usr/bin/swatch --daemon --config-file=/etc/swatch/swatchrc
--tail-file=/u
         sr/local/ha-tomcat/logs/catalina.out
--pid-file=/var/run/swatch.pid
      echo $PID
return $RETVAL
}
stop () {
    # stop daemon
  echo "Stopping swatch:" $PROG
  kill -9 `cat /var/run/swatch.pid`
  rm -f /var/run/swatch.pid
  killall tail
  return $RETVAL
}
restart () {
  stop
  start
  RETVAL=$?
  return $RETVAL
}

case "$1" in
  start)
      start
      ;;
  stop)
      stop
       ;;
  restart)
      restart
      ;;
  *)
      echo "Usage: $0 {start|stop|restart}"
      RETVAL=1
esac
exit $RETVAL


More information about the CentOS mailing list