diff options
Diffstat (limited to 'meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch')
-rw-r--r-- | meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch new file mode 100644 index 0000000000..960ca8e47f --- /dev/null +++ b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch | |||
@@ -0,0 +1,125 @@ | |||
1 | # Write a pid file before forking | ||
2 | # Patch origin: Wind River | ||
3 | |||
4 | Index: nfs-server-2.2beta47/daemon.c | ||
5 | =================================================================== | ||
6 | --- nfs-server-2.2beta47.orig/daemon.c | ||
7 | +++ nfs-server-2.2beta47/daemon.c | ||
8 | @@ -15,6 +15,19 @@ | ||
9 | static const char * pidfilename = 0; | ||
10 | static const char * get_signame(int signo); | ||
11 | |||
12 | +void | ||
13 | +writepid(pid_t pid, int clear) | ||
14 | +{ | ||
15 | + FILE *fp; | ||
16 | + | ||
17 | + fp = fopen(pidfilename, clear? "w" : "a"); | ||
18 | + if (fp == NULL) | ||
19 | + Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename); | ||
20 | + fprintf(fp, "%d\n", pid); | ||
21 | + fclose(fp); | ||
22 | + return; | ||
23 | +} | ||
24 | + | ||
25 | /* | ||
26 | * Do the Crawley Thing | ||
27 | */ | ||
28 | @@ -33,8 +46,10 @@ daemonize(void) | ||
29 | Dprintf(L_FATAL, "unable to fork: %s", strerror(errno)); | ||
30 | |||
31 | /* Parent process: exit */ | ||
32 | - if (c > 0) | ||
33 | + if (c > 0) { | ||
34 | + writepid(c, 1); | ||
35 | exit(0); | ||
36 | + } | ||
37 | |||
38 | /* Do the session stuff */ | ||
39 | close(0); | ||
40 | @@ -60,19 +75,6 @@ setpidpath(const char *filename) | ||
41 | } | ||
42 | |||
43 | void | ||
44 | -writepid(pid_t pid, int clear) | ||
45 | -{ | ||
46 | - FILE *fp; | ||
47 | - | ||
48 | - fp = fopen(pidfilename, clear? "w" : "a"); | ||
49 | - if (fp == NULL) | ||
50 | - Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename); | ||
51 | - fprintf(fp, "%d\n", pid); | ||
52 | - fclose(fp); | ||
53 | - return; | ||
54 | -} | ||
55 | - | ||
56 | -void | ||
57 | failsafe(int level, int ncopies) | ||
58 | { | ||
59 | int *servers, running, child, i; | ||
60 | Index: nfs-server-2.2beta47/mountd.c | ||
61 | =================================================================== | ||
62 | --- nfs-server-2.2beta47.orig/mountd.c | ||
63 | +++ nfs-server-2.2beta47/mountd.c | ||
64 | @@ -425,9 +425,6 @@ main(int argc, char **argv) | ||
65 | background_logging(); | ||
66 | } | ||
67 | |||
68 | - /* Become a daemon */ | ||
69 | - if (!foreground) | ||
70 | - daemonize(); | ||
71 | |||
72 | /* Initialize the FH module. */ | ||
73 | fh_init(); | ||
74 | @@ -435,11 +432,15 @@ main(int argc, char **argv) | ||
75 | /* Initialize the AUTH module. */ | ||
76 | auth_init(auth_file); | ||
77 | |||
78 | - /* Write pidfile */ | ||
79 | if (mount_pid_file == 0) | ||
80 | mount_pid_file = _PATH_MOUNTD_PIDFILE; | ||
81 | setpidpath(mount_pid_file); | ||
82 | - writepid(getpid(), 1); | ||
83 | + | ||
84 | + /* Become a daemon */ | ||
85 | + if (!foreground) | ||
86 | + daemonize(); | ||
87 | + else | ||
88 | + writepid(getpid(), 1); | ||
89 | |||
90 | /* Failsafe mode */ | ||
91 | if (failsafe_level) | ||
92 | Index: nfs-server-2.2beta47/nfsd.c | ||
93 | =================================================================== | ||
94 | --- nfs-server-2.2beta47.orig/nfsd.c | ||
95 | +++ nfs-server-2.2beta47/nfsd.c | ||
96 | @@ -1147,11 +1147,6 @@ main(int argc, char **argv) | ||
97 | /* if (ncopies > 1) | ||
98 | read_only = 1; */ | ||
99 | |||
100 | - /* | ||
101 | - * We first fork off a child and detach from tty | ||
102 | - */ | ||
103 | - if (!foreground) | ||
104 | - daemonize(); | ||
105 | |||
106 | /* Initialize the AUTH module. */ | ||
107 | auth_init(auth_file); | ||
108 | @@ -1160,9 +1155,16 @@ main(int argc, char **argv) | ||
109 | nfs_pid_file = _PATH_NFSD_PIDFILE; | ||
110 | setpidpath(nfs_pid_file); | ||
111 | |||
112 | + /* | ||
113 | + * We first fork off a child and detach from tty | ||
114 | + */ | ||
115 | + if (!foreground) | ||
116 | + daemonize(); | ||
117 | + else | ||
118 | + writepid(getpid(), 1); | ||
119 | + | ||
120 | if (failsafe_level == 0) { | ||
121 | /* Start multiple copies of the server */ | ||
122 | - writepid(getpid(), 1); | ||
123 | for (i = 1; i < ncopies; i++) { | ||
124 | pid_t pid; | ||
125 | |||