#!/bin/sh # Display or kill headless filePro processes. # # Run from cron with -k to kill orphaned fp processes. # Also when the break key screws up, run to kill the child filepro process # to fix your tty session. # Run any time with no options to just see what it would find. # Definition of a "headless" filepro process: # Any filepro binary process whos parent process id is 1 # Because of the more explicit ps and egrep commands used by -k, # the kill option is more exact (safer) than the display options. # It's possible for things to appear in the display that would not get killed # with -k. usage () { echo " headless display all headless filepro processes" echo " headless -e display with environment in less" echo " headless -k kill all headless filepro processes" } case `uname -s` in Linux) BINS="rclerk,dclerk,rreport,dreport,rcabe,dcabe,autoshuf,configed,ddefine,ddir,deddef,dexpand,dmakemenu,dmoedef,dscreen,dxmaint,fpcopy,freechain,menupass,pmaint,runmenu" case "$1" in -k) ps -o pid,ppid -C $BINS |awk '($2==1){print $1}' |xargs -r kill ;; -e) ps e -o tty,pid,ppid,args -C $BINS |awk '($3==1)||($3=="PPID"){print $0}' |less -iS ;; -h) usage ;; *) ps -o tty,pid,ppid,args -C $BINS |awk '($3==1)||($3=="PPID"){print $0}' ;; esac ;; SCO_SV) case "$1" in -k) ps -eo pid,ppid,comm |egrep ' ([dr](clerk|report|cabe)|autoshuf|configed|d(define|dir|eddef|expand|makemenu|moedef|screen|xmaint)|fpcopy|freechain|menupass|pmaint|runmenu)$' |awk '($2==1){print $1}' |xargs kill 2>/dev/null ;; -h) usage ;; *) ps -eo tty,pid,ppid,comm,args |egrep ' (COMMAND|[dr](clerk|report|cabe)|autoshuf|configed|d(define|dir|eddef|expand|makemenu|moedef|screen|xmaint)|fpcopy|freechain|menupass|pmaint|runmenu) ' |awk '($3==1)||($3=="PPID"){print $0}' ;; esac ;; FreeBSD) case "$1" in -k) ps -axco pid,ppid,comm |egrep ' ([dr](clerk|report|cabe)|autoshuf|configed|d(define|dir|eddef|expand|makemenu|moedef|screen|xmaint)|fpcopy|freechain|menupass|pmaint|runmenu)$' |awk '($2==1){print $1}' |xargs kill 2>/dev/null ;; -e) ps -axefwwo tty,pid,ppid,comm,command |egrep '(COMMAND|[dr](clerk|report|cabe)|autoshuf|configed|d(define|dir|eddef|expand|makemenu|moedef|screen|xmaint)|fpcopy|freechain|menupass|pmaint|runmenu)' |awk '($3==1)||($3=="PPID"){print $0}' |less -iS ;; -h) usage ;; *) ps -axfo tty,pid,ppid,comm,args |egrep ' (COMMAND|[dr](clerk|report|cabe)|autoshuf|configed|d(define|dir|eddef|expand|makemenu|moedef|screen|xmaint)|fpcopy|freechain|menupass|pmaint|runmenu) ' |awk '($3==1)||($3=="PPID"){print $0}' ;; esac ;; *) echo "Unrecognized System" ;; esac