dded4d850e520f29a15487c3b2648acfd00f53bc
[openwrt/openwrt.git] / package / fuse / patches / 300-workaround-uclibc-pthread-breakage.patch
1 diff -Nurp fuse-2.8.1.orig/lib/helper.c fuse-2.8.1/lib/helper.c
2 --- fuse-2.8.1.orig/lib/helper.c 2009-06-18 13:14:09.000000000 +0200
3 +++ fuse-2.8.1/lib/helper.c 2009-12-17 01:11:32.773356000 +0100
4 @@ -180,13 +180,41 @@ err:
5 int fuse_daemonize(int foreground)
6 {
7 int res;
8 + int fd;
9
10 if (!foreground) {
11 - res = daemon(0, 0);
12 + /* uClibc daemon() has problems with pthread and friends */
13 + /* workaround from http://www.mail-archive.com/uclibc@uclibc.org/msg01073.html */
14 + /* res = daemon(0, 0); */
15 + switch (res = fork()) {
16 + case -1:
17 + return(-1);
18 + case 0:
19 + break;
20 + default:
21 + _exit(0);
22 + }
23 +
24 if (res == -1) {
25 - perror("fuse: failed to daemonize program\n");
26 + perror("fuse: failed to fork()\n");
27 return -1;
28 }
29 +
30 + res=setsid();
31 +
32 + if (res == -1) {
33 + perror("fuse: failed to setsid()\n");
34 + }
35 +
36 + chdir("/");
37 +
38 + if (fd = open("/dev/null", O_RDWR, 0) != -1) {
39 + dup2(fd, STDIN_FILENO);
40 + dup2(fd, STDOUT_FILENO);
41 + dup2(fd, STDERR_FILENO);
42 + if (fd > 2)
43 + close(fd);
44 + }
45 }
46 return 0;
47 }