diff options
author | David Yip <yipdw@member.fsf.org> | 2018-01-11 04:25:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-11 04:25:26 -0600 |
commit | 8c08c852bcbea32efbd070600c2c13ba6585e6e2 (patch) | |
tree | 78fcc89c2271cc88eed0393d43019d19659f34c4 /stack-fix.c | |
parent | 26f054253c5071d6d56d85f6bc185ae1fc677649 (diff) | |
parent | f13ebd02c91776ddb88b5178bf9015c6e0f1ca80 (diff) |
Merge pull request #320 from glitch-soc/dockerfile-stack-space
dockerfile: Give more stack space to /sbin/tini
Diffstat (limited to 'stack-fix.c')
-rw-r--r-- | stack-fix.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/stack-fix.c b/stack-fix.c new file mode 100644 index 000000000..09311a8f0 --- /dev/null +++ b/stack-fix.c @@ -0,0 +1,32 @@ +#include <dlfcn.h> +#include <pthread.h> +#include <stdio.h> + +// THIS IS TO AVOID A SIGFAULT WHEN RUNNING python3.6 manage.py runserver +// This should be fixed at some point by Alpine and/or Python +// Check this issue for more info +// https://github.com/docker-library/python/issues/211 +typedef int (*func_t)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg); + +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { + + pthread_attr_t local; + int used = 0, ret; + + if (!attr) { + used = 1; + pthread_attr_init(&local); + attr = &local; + } + pthread_attr_setstacksize((void*)attr, 2 * 1024 * 1024); // 2 MB + + func_t orig = (func_t)dlsym(RTLD_NEXT, "pthread_create"); + + ret = orig(thread, attr, start_routine, arg); + + if (used) { + pthread_attr_destroy(&local); + } + + return ret; +} |