mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-02-15 04:43:01 +01:00
Regression fixes from upstream. Rebase uclibc daemon patch, and modify APKBUILD to use patches for the minor releases.
47 lines
1.2 KiB
Diff
47 lines
1.2 KiB
Diff
--- asterisk-11.2.1-orig/main/asterisk.c
|
|
+++ asterisk-11.2.1/main/asterisk.c
|
|
@@ -3891,11 +3891,41 @@
|
|
#if HAVE_WORKING_FORK
|
|
if (ast_opt_always_fork || !ast_opt_no_fork) {
|
|
#ifndef HAVE_SBIN_LAUNCHD
|
|
+#ifndef __UCLIBC__
|
|
if (daemon(1, 0) < 0) {
|
|
fprintf(stderr, "daemon() failed: %s\n", strerror(errno));
|
|
- } else {
|
|
- ast_mainpid = getpid();
|
|
}
|
|
+#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();
|
|
#else
|
|
fprintf(stderr, "Mac OS X detected. Use 'launchctl load /Library/LaunchDaemon/org.asterisk.asterisk.plist'.\n");
|
|
#endif
|