@@ -89,6 +89,30 @@ function __reap ()
89
89
__cleanup
90
90
}
91
91
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
+
92
116
function main ()
93
117
{
94
118
local -r lock_file=" /var/lock/subsys/reaper"
@@ -118,6 +142,9 @@ function main ()
118
142
get=" ${2} "
119
143
shift 2 || break
120
144
;;
145
+ -h|--help)
146
+ __usage
147
+ ;;
121
148
--pid=* )
122
149
pid=" ${1#* =} "
123
150
shift 1
@@ -142,7 +169,7 @@ function main ()
142
169
>&2 printf -- \
143
170
' ERROR: Unknown option %s\n' \
144
171
" ${1} "
145
- exit 1
172
+ __usage
146
173
;;
147
174
esac
148
175
done
@@ -180,7 +207,7 @@ function main ()
180
207
>&2 printf -- \
181
208
' ERROR: Unknown get value %s\n' \
182
209
" ${get} "
183
- exit 1
210
+ __usage
184
211
;;
185
212
esac
186
213
@@ -191,6 +218,12 @@ function main ()
191
218
" ${0##*/ } "
192
219
exit 1
193
220
fi
221
+ elif [[ -n ${get} ]]
222
+ then
223
+ >&2 printf -- \
224
+ ' ERROR: %s is not running\n' \
225
+ " ${0##*/ } "
226
+ __usage
194
227
fi
195
228
196
229
trap __cleanup \
0 commit comments