aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-19 21:23:20 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-19 21:23:20 +0200
commit6d14945e40a63086702ee4d0698032c3708337ed (patch)
tree0dd80b5aae8ca85ad18b44ef763288a666b75e2c
parentset up signal handling (diff)
downloadmds-6d14945e40a63086702ee4d0698032c3708337ed.tar.gz
mds-6d14945e40a63086702ee4d0698032c3708337ed.tar.bz2
mds-6d14945e40a63086702ee4d0698032c3708337ed.tar.xz
m + store master thread
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/mds-base.c12
-rw-r--r--src/mds-base.h8
2 files changed, 17 insertions, 3 deletions
diff --git a/src/mds-base.c b/src/mds-base.c
index ec92571..782f526 100644
--- a/src/mds-base.c
+++ b/src/mds-base.c
@@ -30,17 +30,19 @@
#include <sys/un.h>
#include <unistd.h>
#include <signal.h>
+#include <pthread.h>
#define try(INSTRUCTION) if ((r = INSTRUCTION)) return r
-int argc;
-char** argv;
+int argc = 0;
+char** argv = NULL;
int is_respawn = 0;
int is_reexec = 0;
int socket_fd = -1;
+pthread_t master_thread;
@@ -143,9 +145,13 @@ int main(int argc_, char** argv_)
try (parse_cmdline());
- /* Set up signal traps for all especially handled signals. */
+ /* Store the current thread so it can be killed from elsewhere. */
+ master_thread = pthread_self();
+
+ /* Set up signal traps for all especially handled signals. */
trap_signals();
+
/* Connect to the display. */
if (is_reexec == 0)
try (connect_to_display());
diff --git a/src/mds-base.h b/src/mds-base.h
index e206a78..b4e4ad7 100644
--- a/src/mds-base.h
+++ b/src/mds-base.h
@@ -19,6 +19,9 @@
#define MDS_MDS_BASE_H
+#include <pthread.h>
+
+
/**
* Characteristics of the server
*/
@@ -71,6 +74,11 @@ extern int is_reexec;
*/
extern int socket_fd;
+/**
+ * The thread that runs the master loop
+ */
+extern pthread_t master_thread;
+
/**