[5/6] v4l2-tracer: stop waiting to handle a signal
Commit Message
Usually the v4l2-tracer will wait for its tracee to handle a signal e.g.
from ctrl+c before the v4l2-tracer exits, but if there is no tracee,
then the v4l2-tracer waits forever.
Exit gracefully by waiting only if a tracee exists.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/v4l2-tracer.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
@@ -16,9 +16,12 @@ pid_t tracee_pid = 0;
void v4l2_tracer_sig_handler(int signum)
{
line_info("\n\tReceived signum: %d", signum);
- kill(tracee_pid, signum);
- /* Wait for tracee to handle the signal first before v4l2-tracer exits. */
- wait(nullptr);
+
+ /* If there is a tracee, wait for it to handle the signal first before exiting. */
+ if (tracee_pid) {
+ kill(tracee_pid, signum);
+ wait(nullptr);
+ }
}
enum Options {