1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-07-15 23:50:59 +03:00
openwrt-xburst/package/fuse/patches/300-workaround-uclibc-pthread-breakage.patch
juhosg 89410e0364 package/fuse: refresh patches
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20461 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-03-26 14:28:19 +00:00

47 lines
894 B
Diff

--- a/lib/helper.c
+++ b/lib/helper.c
@@ -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;
}