From eb766b7f4a825bab5a506e6617470499b7d88fe2 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 28 Mar 2003 04:49:09 +0000
Subject: [PATCH] Signal thread not calles thread_up() and thus do_setuid() so
 is no longer running as root.  Signal thread also now writes the PID file so
 there's no incorrect PIDs in the PID file on Linux.

Signals should work correctly in Linux (Finally!)
---
 src/sbbs3/sbbscon.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/sbbs3/sbbscon.c b/src/sbbs3/sbbscon.c
index 133e8cd729..c43c63cfe1 100644
--- a/src/sbbs3/sbbscon.c
+++ b/src/sbbs3/sbbscon.c
@@ -781,6 +781,19 @@ static void handle_sigs(void)  {
 	int		sig;
 	sigset_t			sigs;
 	char		str[1024];
+	FILE*	pidfile;
+
+	thread_up(TRUE,TRUE);
+
+	/* Write the standard .pid file if running as a daemon */
+	/* Must be here so signals are sent to the correct thread */
+	if(is_daemon)  {
+		pidfile=fopen(SBBS_PID_FILE,"w");
+		if(pidfile!=NULL) {
+			fprintf(pidfile,"%d",getpid());
+			fclose(pidfile);
+		}
+	}
 
 	/* Set up blocked signals */
 	sigemptyset(&sigs);
@@ -834,7 +847,6 @@ int main(int argc, char** argv)
 	node_t	node;
 #ifdef __unix__
 	char	daemon_type[2];
-	FILE*	pidfile;
 	struct passwd* pw_entry;
 	struct group*  gr_entry;
 	sigset_t			sigs;
@@ -1366,15 +1378,6 @@ int main(int argc, char** argv)
 
 
 #ifdef __unix__
-	/* Write the standard .pid file if running as a daemon */
-	if(is_daemon)  {
-		pidfile=fopen(SBBS_PID_FILE,"w");
-		if(pidfile!=NULL) {
-			fprintf(pidfile,"%d",getpid());
-			fclose(pidfile);
-		}
-	}
-
 	/* Set up blocked signals */
 	sigemptyset(&sigs);
 	sigaddset(&sigs,SIGINT);
-- 
GitLab