From patchwork Fri Dec 1 00:46:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 13475235 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="mHXr9LGY" Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C1210E2 for ; Thu, 30 Nov 2023 16:47:07 -0800 (PST) Received: from mz550.lan (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dbrouwer) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0C1FA660737B; Fri, 1 Dec 2023 00:47:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701391626; bh=4Hq/uWtQ8beTKXf9zNOJqH3Ehbv5sPy0kl/OgAh7sPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mHXr9LGYIH16RfeaIrngUj4dp4+ejKxcn+9QRG8YcMCOwC7Zy+yywu5fs+LQn4JjN jNbGDuOTaq99KcaR525N+zqSKnU9DNIJiYvNSb7H4+AatgkRFjN3VYWYxmatzdwDft oM23hTvJw0CKa5k7CPr5FnkawQB/BvOcRCywwcKZhaIneJV4fl0ZcRkh72yM19cWSb cuMnwXgdgVFH3n8EF5ywAsr2sX4vitoce0iZfS67mqit8HhQQmlnFpiFxGPGo0khXK jt/HfU8OJpHaVgj1kkUzwEX2rSdjnXCUaaiDB8xRI0Cg9qtJZqP6zHa6EzmA3+mykI X5EEHOwc4Ut7Q== From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil-cisco@xs4all.nl, Deborah Brouwer Subject: [PATCH 5/6] v4l2-tracer: stop waiting to handle a signal Date: Thu, 30 Nov 2023 16:46:33 -0800 Message-ID: <2297fc0ea49ad201d213950c7f32d7ab5e998163.1701390439.git.deborah.brouwer@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 {