FAQ
I have an init script that after running, causes my terminal not to
log out cleanly. Here's what i mean:

# /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?

Search Discussions

  • Matt Hyclak at Oct 24, 2008 at 3:51 pm

    On Fri, Oct 24, 2008 at 10:48:53AM -0500, Sean Carolan enlightened us:
    I have an init script that after running, causes my terminal not to
    log out cleanly. Here's what i mean:

    # /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?

    Matt

    --
    Matt Hyclak
    Systems and Operations
    Office of Information Technology
    Ohio University
    (740) 593-1222
    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: not available
    Type: application/pgp-signature
    Size: 189 bytes
    Desc: not available
    Url : http://lists.centos.org/pipermail/centos/attachments/20081024/dd6f7ffa/attachment.bin
  • Sean Carolan at Oct 24, 2008 at 3:55 pm

    # /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
  • Filipe Brandenburger at Oct 24, 2008 at 3:55 pm
    Hi,
    On Fri, Oct 24, 2008 at 11:48, Sean Carolan wrote:
    # /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?
    Yes, it's because the daemon started from that script keeps file
    descriptors opened to the terminal you are connected to. This might be
    considered a bug in the daemon, since a proper daemon should close all
    its file descriptors before going background and returning to the
    shell.

    You might try to change the script in init.d to append "</dev/null
    /dev/null 2>&1" at the line that starts the daemon, this might force
    it to detach itself from the terminal.

    HTH,
    Filipe
  • Sean Carolan at Oct 24, 2008 at 4:01 pm

    You might try to change the script in init.d to append "</dev/null
    /dev/null 2>&1" at the line that starts the daemon, this might force
    it to detach itself from the terminal.
    This appears to have corrected the issue, thank you very much for the reply.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcentos @
categoriescentos
postedOct 24, '08 at 3:48p
activeOct 24, '08 at 4:01p
posts5
users3
websitecentos.org
irc#centos

People

Translate

site design / logo © 2021 Grokbase