From b30363cc54dfbb718ea7378422b4bf15c9346c0a Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Sat, 8 Aug 2020 02:46:59 -0500
Subject: [PATCH] Rework nest protection

---
 README.md   |  1 +
 firestarter | 18 ++++--------------
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index 627c9f1..7712704 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,7 @@ Firestarter, in addition to spawning the programs in the default configs, also i
 | 53 | Failed to create logging directory |
 | 54 | `HOME` does not exist or is unreadable |
 | 55 | Firestarter is already running |
+| 56 | Firestarter is not running |
 | 70 | No configuration files available |
 
 ## Idiosyncracies
diff --git a/firestarter b/firestarter
index 3b0d067..a9b9534 100755
--- a/firestarter
+++ b/firestarter
@@ -148,7 +148,9 @@ fslist() {
 }
 fsstatus() {
 	# List statistics about firestarter
-	warn "NYI"
+	if [ -z "$FIRESTARTER" ]; then
+		error "Firestarter is not currently running" 56
+	fi
 }
 step_preexecute() {
 	# Special things that can't use simple configuration files
@@ -421,19 +423,7 @@ main() {
 	done
 	# Early hook for help
 	[ -n "$_opthelp" ] && printhelp && exit 0
-	# Ensure our running environment is sane and that we're not about to nest
-	if [ -z "$_optdryrun" ]; then
-		for pid in $(pgrep firestarter); do
-			# Skip invalid PIDs
-			! [ -d "$/proc/$pid" ] && continue
-			# If it's not our session then who cares
-			[ "$_sessionid" != "$(< "/proc/$pid/sessionid")" ] && continue
-			# If it's us then who cares
-			[ "$pid" == "$BASHPID" ] && continue
-			# We care
-			error "Firestarter is already running: $pid" 40
-		done
-	fi
+	# Ensure our running environment is sane
 	if ! [ -d "$HOME" ] || ! [ -r "$HOME" ]; then
 		error "Home directory not found or inaccessable: \"$HOME\"" 54
 	fi