]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
1 | --- daemon.c.orig 2009-11-07 15:29:09.000000000 -0800 |
2 | +++ daemon.c 2009-11-07 15:30:24.000000000 -0800 | |
3 | @@ -33,6 +33,10 @@ static char sccsid[] = "@(#)daemon.c 8.1 | |
224c7076 | 4 | #include <sys/cdefs.h> |
1f2f436a | 5 | __FBSDID("$FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $"); |
224c7076 A |
6 | |
7 | +#ifndef VARIANT_PRE1050 | |
8 | +#include <mach/mach.h> | |
9 | +#include <servers/bootstrap.h> | |
10 | +#endif /* !VARIANT_PRE1050 */ | |
11 | #include "namespace.h" | |
12 | #include <errno.h> | |
13 | #include <fcntl.h> | |
1f2f436a | 14 | @@ -42,6 +46,33 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/dae |
224c7076 A |
15 | #include <unistd.h> |
16 | #include "un-namespace.h" | |
17 | ||
18 | +#ifndef VARIANT_PRE1050 | |
19 | +static void | |
20 | +move_to_root_bootstrap(void) | |
21 | +{ | |
22 | + mach_port_t parent_port = 0; | |
23 | + mach_port_t previous_port = 0; | |
24 | + | |
25 | + do { | |
26 | + if (previous_port) { | |
27 | + mach_port_deallocate(mach_task_self(), previous_port); | |
28 | + previous_port = parent_port; | |
29 | + } else { | |
30 | + previous_port = bootstrap_port; | |
31 | + } | |
32 | + | |
33 | + if (bootstrap_parent(previous_port, &parent_port) != 0) { | |
34 | + return; | |
35 | + } | |
36 | + } while (parent_port != previous_port); | |
37 | + | |
38 | + task_set_bootstrap_port(mach_task_self(), parent_port); | |
39 | + bootstrap_port = parent_port; | |
40 | +} | |
41 | +#endif /* !VARIANT_PRE1050 */ | |
42 | + | |
43 | +int daemon(int, int) __DARWIN_1050(daemon); | |
44 | + | |
45 | int | |
46 | daemon(nochdir, noclose) | |
47 | int nochdir, noclose; | |
1f2f436a | 48 | @@ -57,7 +88,9 @@ daemon(nochdir, noclose) |
224c7076 A |
49 | sa.sa_handler = SIG_IGN; |
50 | sa.sa_flags = 0; | |
51 | osa_ok = _sigaction(SIGHUP, &sa, &osa); | |
52 | - | |
53 | +#ifndef VARIANT_PRE1050 | |
54 | + move_to_root_bootstrap(); | |
55 | +#endif /* !VARIANT_PRE1050 */ | |
56 | switch (fork()) { | |
57 | case -1: | |
58 | return (-1); |