1 autofs-5.0.4 - fix return start status on fail
3 From: Ian Kent <raven@themaw.net>
5 We're not returning the status to the parent when automount(8) is waiting
6 for the daemon to finish its startup.
10 daemon/automount.c | 27 +++++++++++++++++++++------
11 2 files changed, 22 insertions(+), 6 deletions(-)
14 diff --git a/CHANGELOG b/CHANGELOG
15 index fdde400..2cb35dc 100644
19 - add WITH_LIBTIRPC to -V status report.
20 - add nfs mount protocol default configuration option.
21 - fix bad token declaration in master map parser.
22 +- fix return start status on fail.
24 4/11/2008 autofs-5.0.4
25 -----------------------
26 diff --git a/daemon/automount.c b/daemon/automount.c
27 index 776c92c..80691fa 100644
28 --- a/daemon/automount.c
29 +++ b/daemon/automount.c
30 @@ -60,7 +60,7 @@ long global_negative_timeout = -1;
31 int do_force_unlink = 0; /* Forceably unlink mount tree at startup */
33 static int start_pipefd[2];
34 -static int st_stat = 0;
35 +static int st_stat = 1;
36 static int *pst_stat = &st_stat;
37 static pthread_t state_mach_thid;
39 @@ -1046,6 +1046,7 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
42 char buf[MAX_ERR_BUF];
46 /* Don't BUSY any directories unnecessarily */
47 @@ -1072,10 +1073,9 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
52 close(start_pipefd[1]);
53 - r = read(start_pipefd[0], pst_stat, sizeof(*pst_stat));
55 + res = read(start_pipefd[0], pst_stat, sizeof(*pst_stat));
60 @@ -1088,8 +1088,13 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
61 if (daemon_check && !aquire_flag_file()) {
62 fprintf(stderr, "%s: program is already running.\n",
64 + /* Return success if already running */
66 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
69 close(start_pipefd[1]);
75 @@ -1099,8 +1104,9 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
77 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
78 fprintf(stderr, "setsid: %s", estr);
79 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
80 close(start_pipefd[1]);
86 @@ -1991,6 +1997,7 @@ int main(int argc, char *argv[])
88 logerr("%s: can't create master map %s",
90 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
91 close(start_pipefd[1]);
94 @@ -1999,6 +2006,7 @@ int main(int argc, char *argv[])
95 if (pthread_attr_init(&th_attr)) {
96 logerr("%s: failed to init thread attribute struct!",
98 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
99 close(start_pipefd[1]);
102 @@ -2007,6 +2015,7 @@ int main(int argc, char *argv[])
103 if (pthread_attr_init(&th_attr_detached)) {
104 logerr("%s: failed to init thread attribute struct!",
106 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
107 close(start_pipefd[1]);
110 @@ -2016,6 +2025,7 @@ int main(int argc, char *argv[])
111 &th_attr_detached, PTHREAD_CREATE_DETACHED)) {
112 logerr("%s: failed to set detached thread attribute!",
114 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
115 close(start_pipefd[1]);
118 @@ -2026,6 +2036,7 @@ int main(int argc, char *argv[])
119 &th_attr_detached, PTHREAD_STACK_MIN*64)) {
120 logerr("%s: failed to set stack size thread attribute!",
122 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
123 close(start_pipefd[1]);
126 @@ -2043,6 +2054,7 @@ int main(int argc, char *argv[])
127 logerr("%s: failed to create thread data key for std env vars!",
129 master_kill(master_list);
130 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
131 close(start_pipefd[1]);
134 @@ -2053,6 +2065,7 @@ int main(int argc, char *argv[])
135 if (!alarm_start_handler()) {
136 logerr("%s: failed to create alarm handler thread!", program);
137 master_kill(master_list);
138 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
139 close(start_pipefd[1]);
142 @@ -2061,6 +2074,7 @@ int main(int argc, char *argv[])
143 if (!st_start_handler()) {
144 logerr("%s: failed to create FSM handler thread!", program);
145 master_kill(master_list);
146 + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
147 close(start_pipefd[1]);
150 @@ -2092,6 +2106,7 @@ int main(int argc, char *argv[])
155 res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
156 close(start_pipefd[1]);