]>
Commit | Line | Data |
---|---|---|
224c7076 A |
1 | --- daemon.c.orig 2007-09-29 23:58:54.000000000 -0700 |
2 | +++ daemon.c 2007-09-30 00:46:19.000000000 -0700 | |
3 | @@ -37,6 +37,10 @@ | |
4 | #include <sys/cdefs.h> | |
5 | __FBSDID("$FreeBSD: src/lib/libc/gen/daemon.c,v 1.6 2003/11/10 22:01:42 ghelmer Exp $"); | |
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> | |
14 | @@ -45,6 +49,33 @@ | |
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; | |
48 | @@ -60,7 +91,9 @@ | |
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); |