summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-01-08 16:21:52 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-01-08 16:21:52 +0000
commitba66d54b5f4064664c69f614d55814cc6e862997 (patch)
tree2c762bcb0745ae549362698d69716de4988d3953 /contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch
parent2498f604961ebcf0bc8094bb72fd77d63670ee72 (diff)
contrib/package: move asterisk14-xip to feed
Diffstat (limited to 'contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch')
-rw-r--r--contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch b/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch
new file mode 100644
index 0000000000..262bed4a74
--- /dev/null
+++ b/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch
@@ -0,0 +1,42 @@
+diff -Nru asterisk-1.4.22.org/main/asterisk.c asterisk-1.4.22/main/asterisk.c
+--- asterisk-1.4.22.org/main/asterisk.c 2008-07-26 17:31:21.000000000 +0200
++++ asterisk-1.4.22/main/asterisk.c 2008-12-20 22:49:58.000000000 +0100
+@@ -2935,7 +2935,38 @@
+ #if HAVE_WORKING_FORK
+ if (ast_opt_always_fork || !ast_opt_no_fork) {
+ #ifndef HAVE_SBIN_LAUNCHD
++#ifndef __UCLIBC__
+ daemon(1, 0);
++#else
++/*
++ workaround for uClibc-0.9.29 mipsel bug:
++ recursive mutexes do not work if uClibc daemon() function has been called,
++ if parent thread locks a mutex
++ the child thread cannot acquire a lock with the same name
++ (same code works if daemon() is not called)
++ but duplication of uClibc daemon.c code in here does work.
++*/
++ int fd;
++ switch (fork()) {
++ case -1:
++ exit(1);
++ case 0:
++ break;
++ default:
++ _exit(0);
++ }
++ if (setsid() == -1)
++ exit(1);
++ if (fork())
++ _exit(0);
++ 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);
++ }
++#endif
+ ast_mainpid = getpid();
+ /* Blindly re-write pid file since we are forking */
+ unlink(ast_config_AST_PID);