ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/util.C
(Generate patch)

Comparing gvpe/src/util.C (file contents):
Revision 1.18 by pcg, Fri Mar 18 02:32:20 2005 UTC vs.
Revision 1.19 by pcg, Wed Mar 23 21:55:39 2005 UTC

127 slog (L_INFO, _("gvpe daemon %s (%s %s) starting"), VERSION, __DATE__, __TIME__); 127 slog (L_INFO, _("gvpe daemon %s (%s %s) starting"), VERSION, __DATE__, __TIME__);
128 128
129 return 0; 129 return 0;
130} 130}
131 131
132void run_script (const run_script_cb &cb, bool wait) 132bool run_script (const run_script_cb &cb, bool wait)
133{ 133{
134 int pid; 134 int pid;
135 135
136 if ((pid = fork ()) == 0) 136 if ((pid = fork ()) == 0)
137 { 137 {
138 char *filename; 138 execl ("/bin/sh", "/bin/sh", "-c", cb (), (char *) 0);
139 asprintf (&filename, "%s/%s", confbase, cb()); 139 exit (EXIT_FAILURE);
140 execl (filename, filename, (char *) 0);
141 exit (126);
142 } 140 }
143 else if (pid > 0) 141 else if (pid > 0)
144 { 142 {
145 if (wait) 143 if (wait)
146 { 144 {
145 int status;
146
147 waitpid (pid, 0, 0); 147 if (waitpid (pid, &status, 0) < 0)
148 /* TODO: check status */ 148 {
149 slog (L_WARN, _("waiting for an external command failed: %s."),
150 strerror (errno));
151 return false;
152 }
153 else if (!WIFEXITED (status) || WEXITSTATUS (status) != EXIT_SUCCESS)
154 {
155 slog (L_WARN, _("external command returned with exit status %d (%04x)."),
156 WEXITSTATUS (status), status);
157 return false;
158 }
149 } 159 }
150 } 160 }
161
162 return true;
151} 163}
152 164
153#if ENABLE_HTTP_PROXY 165#if ENABLE_HTTP_PROXY
154// works like strdup 166// works like strdup
155u8 * 167u8 *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines