diff options
Diffstat (limited to 'src/libthread')
-rw-r--r-- | src/libthread/bg.c | 7 | ||||
-rw-r--r-- | src/libthread/daemonize.c | 12 | ||||
-rw-r--r-- | src/libthread/mkfile | 1 | ||||
-rw-r--r-- | src/libthread/thread.c | 2 |
4 files changed, 15 insertions, 7 deletions
diff --git a/src/libthread/bg.c b/src/libthread/bg.c new file mode 100644 index 00000000..2edbc0e4 --- /dev/null +++ b/src/libthread/bg.c @@ -0,0 +1,7 @@ +#include "threadimpl.h" + +int +threadmaybackground(void) +{ + return 0; +} diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c index 387d1527..f994ffe1 100644 --- a/src/libthread/daemonize.c +++ b/src/libthread/daemonize.c @@ -8,7 +8,7 @@ #undef wait static int sigpid; -static int threadpassfd; +static int threadpassfd = -1; static int gotsigchld; static void @@ -163,9 +163,9 @@ _threadsetupdaemonize(void) void _threaddaemonize(void) { - if(threadpassfd >= 0){ - write(threadpassfd, "0", 1); - close(threadpassfd); - threadpassfd = -1; - } + if(threadpassfd < 0) + sysfatal("threads in main proc exited w/o threadmaybackground"); + write(threadpassfd, "0", 1); + close(threadpassfd); + threadpassfd = -1; } diff --git a/src/libthread/mkfile b/src/libthread/mkfile index 8a77a316..eca4f4df 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -4,6 +4,7 @@ SYSOFILES=`{sh ./sysofiles.sh} LIB=libthread.a OFILES=\ $SYSOFILES\ + bg.$O\ channel.$O\ daemonize.$O\ exec.$O\ diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 65e65194..7151e875 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -844,7 +844,7 @@ main(int argc, char **argv) // Easier to just run in pthread-per-thread mode. pthreadperthread = 1; #endif - if(strstr(opts, "nodaemon") == nil && getenv("NOLIBTHREADDAEMONIZE") == nil) + if(threadmaybackground() && strstr(opts, "nodaemon") == nil && getenv("NOLIBTHREADDAEMONIZE") == nil) _threadsetupdaemonize(); threadargc = argc; |