[PATCH 5/6] v4l2-tracer: stop waiting to handle a signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 utils/v4l2-tracer/v4l2-tracer.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/utils/v4l2-tracer/v4l2-tracer.cpp b/utils/v4l2-tracer/v4l2-tracer.cpp
index 37e17eb6..05e5b368 100644
--- a/utils/v4l2-tracer/v4l2-tracer.cpp
+++ b/utils/v4l2-tracer/v4l2-tracer.cpp
@@ -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 {
-- 
2.41.0





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux