@@ -89,6 +89,30 @@ function __reap ()
8989 __cleanup
9090}
9191
92+ function __usage ()
93+ {
94+ cat << -EOF
95+ Usage: ${0##*/ } [OPTIONS]
96+ ${0##*/ } [{-h|--help}]
97+
98+ Options:
99+ -g, --get KEY Used to get values from a running ${0##*/ }
100+ process. The keys and values they return are:
101+ - start : returns session start timestamp.
102+ - end : returns session end timestamp.
103+ - ttl : returns remaining session time to live.
104+ -h, --help Show this help and exit.
105+ -p, --pid PID Send the termination signal to the process with
106+ the pid value PID.
107+ If not specified the default is pid 1.
108+ -s, --signal SIG Send the signal SIG to the process.
109+ If not specified the default is SIGTERM.
110+ -v, --verbose Output informational messages.
111+ If not specified the default is quiet.
112+ EOF
113+ exit 1
114+ }
115+
92116function main ()
93117{
94118 local -r lock_file=" /var/lock/subsys/reaper"
@@ -118,6 +142,9 @@ function main ()
118142 get=" ${2} "
119143 shift 2 || break
120144 ;;
145+ -h|--help)
146+ __usage
147+ ;;
121148 --pid=* )
122149 pid=" ${1#* =} "
123150 shift 1
@@ -142,7 +169,7 @@ function main ()
142169 >&2 printf -- \
143170 ' ERROR: Unknown option %s\n' \
144171 " ${1} "
145- exit 1
172+ __usage
146173 ;;
147174 esac
148175 done
@@ -180,7 +207,7 @@ function main ()
180207 >&2 printf -- \
181208 ' ERROR: Unknown get value %s\n' \
182209 " ${get} "
183- exit 1
210+ __usage
184211 ;;
185212 esac
186213
@@ -191,6 +218,12 @@ function main ()
191218 " ${0##*/ } "
192219 exit 1
193220 fi
221+ elif [[ -n ${get} ]]
222+ then
223+ >&2 printf -- \
224+ ' ERROR: %s is not running\n' \
225+ " ${0##*/ } "
226+ __usage
194227 fi
195228
196229 trap __cleanup \
0 commit comments