#!/bin/sh # # --------- # AiresKill # --------- # # This is a sh script to kill AIRES processes currently running. # The processes will be killed without saving the work already # done. If you want an ordered shutdown, use script AiresStop instead. # # Written by S. J. Sciutto, La Plata 1996, 1997, 1998, 2001. # # Last modification: 05/Nov/2001. # # # Usage: # # AiresKill [-q | -f] [spoolnumber] # # ############################################################################### # # Setting predefinded constants. # AiresSet="${HOME}/.airesrc" if [ -f $AiresSet ] then . $AiresSet else # # .airesrc file does not exist, trying in default bin directory. # AiresSet="${HOME}/aires/current/bin/airesrc" if [ -f $AiresSet ] then . $AiresSet else # # Have no other ideas about the setting file. # echo echo Cannot find internal script file! echo exit fi fi # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Analysing the input parameters. # case _$1 in # _) # No arguments. Verbose and querying mode. verb=verbose inqu=inquire ;; _-q) verb= inqu= shift ;; _-f) verb=verbose inqu= shift ;; _-*) echo "Usage: AiresKill [-q | -f] [spoolnumber]" exit ;; _*) # Only spool arguments. Verbose and querying mode. verb=verbose inqu=inquire ;; esac # # Completing the definition of constants. # if [ $1 ] then spoolnumber=$1 fi . ${Airesbindir}/AiresSetParams # currdir="`pwd`" # # Checking the current status of the runner system. # cd $spooldir # spoolfiles=$spoolfiledef if [ "_$spoolfiles" != "_`echo $spoolfiledef`" ] then # # There are tasks in spool. Checking if AiresRunner is up. # if [ -f $rpf ] then # # There is a PID file. Checking if the process exists. # pidinfo="`cat $rpf`" set xxx $pidinfo pid=$2 # oatp= if [ "_$AiresTestProcess" != "_" ] then atp=$AiresTestProcess if [ -x $atp ] then oatp=TRUE fi fi # if [ $oatp ] then running="`$atp $pidinfo`" else $pscomm > __AIRES_KILL.TMP nproc="`grep -c $pid __AIRES_KILL.TMP`" rm -f __AIRES_KILL.TMP if [ $nproc = 0 ] then running=NO else running=YES fi fi # if [ $running = YES ] then noprocess= elif [ $running = NO ] then noprocess=TRUE if [ $verb ] then echo "Detected aborted AiresRunner process (PID number $pid)." fi else noprocess= echo PID file exists but status of process is unknown. fi # else # # No PID file. # noprocess=TRUE # fi # if [ $noprocess ] then # # There are no processes. # if [ $verb ] then echo "No processes to kill." fi # else # # There is a process running right now. # if [ $inqu ] then # echo echo "Detected a running process (PID number $pid)." $echonlf "Do you wish to kill it now?: " read sw echo if [ "_$sw" = "_y" -o "_$sw" = "_Y" -o \ "_$sw" = "_yes" -o "_$sw" = "_YES" -o "_$sw" = "_Yes" ] then goon=TRUE else goon= fi # else goon=TRUE fi # # Killing the processes. # if [ $goon ] then # if [ $oatp ] then $atp -kill $pidinfo rc=$? if [ $rc = 0 ] then echo "Process(es) killed using external script." else echo Nonzero return code from external script. fi else # $psjob > __AIRES_KILL.TMP1 grep PID __AIRES_KILL.TMP1 > __AIRES_KILL.TMP2 set `cat __AIRES_KILL.TMP2` ccol=0 for i in 1 2 3 4 5 6 7 8 9; do if [ $i -le $# ] then tmp="\$$i" eval tmp=$tmp if [ $tmp = PID ] then ccol=$i fi fi done if [ $ccol -le 0 ] then echo echo "Cannot determine child process(es)." echo "No process(es) killed." rm __AIRES_KILL.TMP* exit fi rm __AIRES_KILL.TMP2 grep $pid __AIRES_KILL.TMP1 > __AIRES_KILL.TMP2 echo "" > __AIRES_KILL.LOCK ${Airesbindir}/AiresKillAux1 $ccol < __AIRES_KILL.TMP2 rm -f $rlf $rpf # if [ $verb ] then echo "The following process(es) were killed" cat __AIRES_KILL.LOCK echo fi fi # elif [ $verb ] then echo No processes killed. fi # fi # else # # There are no tasks in spool. # if [ $verb ] then echo No tasks in spool ${spoolnumber}. fi # fi # rm -f __AIRES_KILL.* cd $currdir exit # # This script file is part of the AIRES Runner System; # AIRES 2.8.4a distribution. # # xxx 0 Tue Dec 12 16:28:05 ART 2006