rspamd_fprintf (stderr, "Cannot execute %s: %e", execute, exec_err);
g_error_free (exec_err);
+
+ exit (EXIT_FAILURE);
}
else {
children = g_list_prepend (children, GSIZE_TO_POINTER (cld));
gint
main (gint argc, gchar **argv, gchar **env)
{
- gint i, start_argc, cur_req = 0, res;
+ gint i, start_argc, cur_req = 0, res, ret;
GQueue *kwattrs;
GList *cur;
GPid cld;
/* Wait for children processes */
cur = g_list_first (children);
+ ret = 0;
while (cur) {
cld = GPOINTER_TO_SIZE (cur->data);
if (waitpid (cld, &res, 0) == -1) {
fprintf (stderr, "Cannot wait for %d: %s", (gint)cld,
strerror (errno));
+
+ ret = errno;
+ }
+
+ if (ret == 0) {
+ /* Check return code */
+ if (WIFSIGNALED (res)) {
+ ret = WTERMSIG (res);
+ }
+ else if (WIFEXITED (res)) {
+ ret = WEXITSTATUS (res);
+ }
}
cur = g_list_next (cur);
g_list_free (children);
}
- return 0;
+ return ret;
}