[PATCH 1/4] restorecond: switch terminate to sig_atomic_t for async-signal-safety

Stephen Smalley <[email protected]>
Newsgroups org.kernel.vger.selinux
Message-ID <[email protected]>
The terminate flag is written from a signal handler so switch it to
volatile sig_atomic_t for async-signal-safety.

Signed-off-by: Stephen Smalley <[email protected]>
---
 restorecond/restorecond.c | 2 +-
 restorecond/restorecond.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/restorecond/restorecond.c b/restorecond/restorecond.c
index b8ca4b21..0e973d83 100644
--- a/restorecond/restorecond.c
+++ b/restorecond/restorecond.c
@@ -73,7 +73,7 @@ struct restore_opts r_opts;
 #include <selinux/selinux.h>
 
 int debug_mode = 0;
-int terminate = 0;
+volatile sig_atomic_t terminate = 0;
 int master_wd = -1;
 int run_as_user = 0;
 int foreground_mode = 0;
diff --git a/restorecond/restorecond.h b/restorecond/restorecond.h
index 9fb5c5d5..7e209226 100644
--- a/restorecond/restorecond.h
+++ b/restorecond/restorecond.h
@@ -24,9 +24,11 @@
 #ifndef RESTORED_CONFIG_H
 #define RESTORED_CONFIG_H
 
+#include <signal.h>
+
 extern int debug_mode;
 extern const char *homedir;
-extern int terminate;
+extern volatile sig_atomic_t terminate;
 extern int master_wd;
 extern int run_as_user;
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.