console-server: Define static sigint object as `volatile sig_atomic_t`
The C language defines that access to any other type, of static storage
duration, in a signal handler, yields undefined-behavior. Avoid the
problem given that compilers like to assume undefined behavior doesn't
occur.
Change-Id: I3cd37d7933c6c759aa52b11e3fdbecfe07e25981
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/console-server.c b/console-server.c
index 40c3288..dde3ca2 100644
--- a/console-server.c
+++ b/console-server.c
@@ -46,7 +46,7 @@
const size_t default_buffer_size = 128ul * 1024ul;
/* state shared with the signal handler */
-static bool sigint;
+static volatile sig_atomic_t sigint;
static void usage(const char *progname)
{
@@ -841,7 +841,7 @@
static void sighandler(int signal)
{
if (signal == SIGINT) {
- sigint = true;
+ sigint = 1;
}
}