You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
921 B

  1. #include <dlfcn.h>
  2. #include <pthread.h>
  3. #include <stdio.h>
  4. // THIS IS TO AVOID A SIGFAULT WHEN RUNNING python3.6 manage.py runserver
  5. // This should be fixed at some point by Alpine and/or Python
  6. // Check this issue for more info
  7. // https://github.com/docker-library/python/issues/211
  8. typedef int (*func_t)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg);
  9. int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) {
  10. pthread_attr_t local;
  11. int used = 0, ret;
  12. if (!attr) {
  13. used = 1;
  14. pthread_attr_init(&local);
  15. attr = &local;
  16. }
  17. pthread_attr_setstacksize((void*)attr, 2 * 1024 * 1024); // 2 MB
  18. func_t orig = (func_t)dlsym(RTLD_NEXT, "pthread_create");
  19. ret = orig(thread, attr, start_routine, arg);
  20. if (used) {
  21. pthread_attr_destroy(&local);
  22. }
  23. return ret;
  24. }