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?
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-0003.sig>
Filipe Brandenburger
2008-Oct-24 15:55 UTC
[CentOS] Certain scripts "hang" the terminal on logout
Hi, On Fri, Oct 24, 2008 at 11:48, Sean Carolan <scarolan at gmail.com> 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 forceit to detach itself from the terminal. HTH, Filipe
>> # /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