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