The fix adds another reporting flag, LIBREPORT_GETPID,
which means "return the pid of reporting process".
IOW: LIBREPORT_NOWAIT will reparent reporter to init,
LIBREPORT_NOWAIT | LIBREPORT_GETPID will not.
By using LIBREPORT_NOWAIT | LIBREPORT_GETPID in abt-gui,
we make it so that reporter's SIGCHLD reaches abrt-gui
and lets it refresh the list.
Please review.
--
vda
diff -x '*.po' -d -urpN abrt.1/src/gui-gtk/main.c abrt.2/src/gui-gtk/main.c
--- abrt.1/src/gui-gtk/main.c 2011-07-20 19:26:26.026789417 +0200
+++ abrt.2/src/gui-gtk/main.c 2011-07-21 09:23:45.491335774 +0200
@@ -204,7 +204,7 @@ static void on_row_activated_cb(GtkTreeV
gtk_tree_model_get_value(store, &iter, COLUMN_DUMP_DIR, &d_dir);
const char *dirname = g_value_get_string(&d_dir);
- report_problem_in_dir(dirname, LIBREPORT_ANALYZE | LIBREPORT_NOWAIT);
+ report_problem_in_dir(dirname, LIBREPORT_ANALYZE | LIBREPORT_NOWAIT | LIBREPORT_GETPID);
}
}
}
@@ -293,8 +293,7 @@ static void on_button_send_cb(GtkWidget
/* why it doesn't want to hide before report ends? */
gtk_widget_destroy(s_report_window);
- int status = report_problem_in_memory(pd, LIBREPORT_NOWAIT);
- VERB1 log("Reporting finished with status %i", status);
+ report_problem_in_memory(pd, LIBREPORT_NOWAIT | LIBREPORT_GETPID);
free_problem_data(pd);
}
diff -x '*.po' -d -urpN libreport.4/src/include/report.h libreport.5/src/include/report.h
--- libreport.4/src/include/report.h 2011-07-19 11:48:22.000000000 +0200
+++ libreport.5/src/include/report.h 2011-07-21 09:21:34.913290086 +0200
@@ -28,10 +28,13 @@ extern "C" {
enum {
LIBREPORT_NOWAIT = 0,
LIBREPORT_WAIT = (1 << 0), /* wait for report to finish and reload the problem data */
- LIBREPORT_ANALYZE = (1 << 1), /* run analyzers? */
+ LIBREPORT_GETPID = (1 << 1), /* return pid of child. Use with LIBREPORT_NOWAIT. */
+ /* Note: without LIBREPORT_GETPID, child will be detached */
+ /* (reparented to init) */
+ LIBREPORT_ANALYZE = (1 << 2), /* run analyzers? */
/* ("run reporters" is always on, has no flag (for now?)) */
- LIBREPORT_RELOAD_DATA = (1 << 3), /* reload problem data after run (needs WAIT) */
- LIBREPORT_DEL_DIR = (1 << 4), /* delete directory after reporting */
+ LIBREPORT_RELOAD_DATA = (1 << 5), /* reload problem data after run (needs WAIT) */
+ LIBREPORT_DEL_DIR = (1 << 6), /* delete directory after reporting */
};
int report_problem_in_dir(const char *dirname, int flags);
diff -x '*.po' -d -urpN libreport.4/src/lib/report.c libreport.5/src/lib/report.c
--- libreport.4/src/lib/report.c 2011-07-19 11:48:22.000000000 +0200
+++ libreport.5/src/lib/report.c 2011-07-21 09:19:35.521766262 +0200
@@ -74,9 +74,10 @@ int report_problem_in_dir(const char *di
*/
signal(SIGCHLD, SIG_DFL);
- if (!(flags & LIBREPORT_WAIT))
+ if (!(flags & (LIBREPORT_WAIT | LIBREPORT_GETPID)))
{
- /* Caller doesn't want to wait for completion.
+ /* Caller doesn't want to wait for completion (!LIBREPORT_WAIT),
+ * and doesn't want to have pid returned (!LIBREPORT_GETPID).
* Create a grandchild, and then exit.
* This reparents grandchild to init, and makes waitpid
* in parent detect our exit and return almost immediately.
@@ -120,6 +121,13 @@ int report_problem_in_dir(const char *di
}
/* parent */
+ if (!(flags & LIBREPORT_WAIT) && (flags & LIBREPORT_GETPID))
+ return pid;
+
+ /* we are here either if LIBREPORT_WAIT (caller wants exitcode)
+ * or !LIBREPORT_GETPID (caller doesn't want to have a child).
+ * In both cases, we need to wait for child:
+ */
int status;
do
pid = waitpid(pid, &status, 0);
@@ -150,7 +158,7 @@ int report_problem_in_memory(problem_dat
dd_close(dd);
VERB2 log("Temp problem dir: '%s'", dir_name);
- if (!(flags & LIBREPORT_WAIT))
+ if (flags & LIBREPORT_NOWAIT)
flags |= LIBREPORT_DEL_DIR;
result = report_problem_in_dir(dir_name, flags);
diff -x '*.po' -d -urpN libreport.4/src/report-python/reportmodule.c libreport.5/src/report-python/reportmodule.c
--- libreport.4/src/report-python/reportmodule.c 2011-07-19 11:48:22.000000000 +0200
+++ libreport.5/src/report-python/reportmodule.c 2011-07-21 09:22:11.027762251 +0200
@@ -90,6 +90,7 @@ init_pyreport(void)
/* for include/report/report.h */
PyModule_AddObject(m, "LIBREPORT_NOWAIT" , Py_BuildValue("i", LIBREPORT_NOWAIT ));
PyModule_AddObject(m, "LIBREPORT_WAIT" , Py_BuildValue("i", LIBREPORT_WAIT ));
+ PyModule_AddObject(m, "LIBREPORT_GETPID" , Py_BuildValue("i", LIBREPORT_GETPID ));
PyModule_AddObject(m, "LIBREPORT_ANALYZE" , Py_BuildValue("i", LIBREPORT_ANALYZE ));
PyModule_AddObject(m, "LIBREPORT_RELOAD_DATA", Py_BuildValue("i", LIBREPORT_RELOAD_DATA));
PyModule_AddObject(m, "LIBREPORT_DEL_DIR" , Py_BuildValue("i", LIBREPORT_DEL_DIR ));