summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/rc24
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/rc b/bin/rc
index ae77113..8b14849 100755
--- a/bin/rc
+++ b/bin/rc
@@ -263,10 +263,25 @@ status()
return 0
}
+quit()
+{
+ if mkfifo -m 0600 "${rc_fifo}" 2>/dev/null; then
+ # Daemonizing just to quit makes no sense.
+ error 'No running daemon found'
+ rm "${rc_fifo}"
+ return 1
+ else
+ # Signal the running rc daemon.
+ printf '%s bye\n' "${MAGIC}" 1>"${rc_fifo}"
+ fi
+
+ return 0
+}
+
usage()
{
printf 'Usage: %s {start|stop} <session-type>\n' "${0}"
- printf ' or: %s status\n\n' "${0}"
+ printf ' or: %s {status|quit}\n\n' "${0}"
printf '<session-type> is one or more strings of alphanumeric '
printf 'characters\nseparated by colons.\n'
@@ -298,6 +313,13 @@ main()
fi
status
;;
+ 'quit')
+ if [ ${#} -ne 1 ]; then
+ usage 1>&2
+ return 1
+ fi
+ quit
+ ;;
*)
usage 1>&2
return 1