300-workaround-uclibc-pthread-breakage.patch 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --- fuse-2.7.3.orig/lib/helper.c 2008-11-22 03:25:11.000000000 +0100
  2. +++ fuse-2.7.3/lib/helper.c 2008-11-22 04:06:35.000000000 +0100
  3. @@ -178,13 +178,41 @@
  4. int fuse_daemonize(int foreground)
  5. {
  6. int res;
  7. + int fd;
  8. if (!foreground) {
  9. - res = daemon(0, 0);
  10. + /* uClibc daemon() has problems with pthread and friends */
  11. + /* workaround from http://www.mail-archive.com/[email protected]/msg01073.html */
  12. + /* res = daemon(0, 0); */
  13. + switch (res = fork()) {
  14. + case -1:
  15. + return(-1);
  16. + case 0:
  17. + break;
  18. + default:
  19. + _exit(0);
  20. + }
  21. +
  22. if (res == -1) {
  23. - perror("fuse: failed to daemonize program\n");
  24. + perror("fuse: failed to fork()\n");
  25. return -1;
  26. }
  27. +
  28. + res=setsid();
  29. +
  30. + if (res == -1) {
  31. + perror("fuse: failed to setsid()\n");
  32. + }
  33. +
  34. + chdir("/");
  35. +
  36. + if (fd = open("/dev/null", O_RDWR, 0) != -1) {
  37. + dup2(fd, STDIN_FILENO);
  38. + dup2(fd, STDOUT_FILENO);
  39. + dup2(fd, STDERR_FILENO);
  40. + if (fd > 2)
  41. + close(fd);
  42. + }
  43. }
  44. return 0;
  45. }