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@xxxxxxxxx> --- src/ftracepy-utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index 8e803ee..b5cdcee 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -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); } -- 2.32.0