@@ -2097,10 +2097,17 @@ static void iterate_raw_events_waitpid(struct tracefs_instance *instance,
PyObject *py_func,
pid_t pid)
{
+ bool *callback_status = &callback_ctx.status;
+ int ret;
+
callback_ctx.py_callback = py_func;
+ (*(volatile bool *)callback_status) = true;
do {
- tracefs_iterate_raw_events(tep, instance, NULL, 0,
- callback, &callback_ctx);
+ ret = tracefs_iterate_raw_events(tep, instance, NULL, 0,
+ callback, &callback_ctx);
+
+ if (*(volatile bool *)callback_status == false || ret < 0)
+ break;
} while (waitpid(pid, NULL, WNOHANG) != pid);
}
Both 'trace_process()' and 'trace_shell_process()' can be stopped from the callback function by calling 'sys.exit()' or by returning non zero integer value. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/ftracepy-utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)