From: Florian Westphal <fw@strlen.de>
To: Phil Sutter <phil@nwl.cc>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH v3] configure: Implement --enable-profiling option
Date: Thu, 12 Feb 2026 01:08:17 +0100 [thread overview]
Message-ID: <aY0Z63yPjQoXYp9b@strlen.de> (raw)
In-Reply-To: <20260211201503.27186-1-phil@nwl.cc>
Phil Sutter <phil@nwl.cc> wrote:
> This will set compiler flag --coverage so code coverage may be inspected
> using gcov.
>
> In order to successfully profile processes which are killed or
> interrupted as well, add a signal handler for those cases which calls
> exit(). This is relevant for test cases invoking nft monitor.
>
> index 0000000000000..912ead9d7eb94
> --- /dev/null
> +++ b/src/profiling.c
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright (c) Red Hat GmbH. Author: Phil Sutter <phil@nwl.cc>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 (or any
> + * later) as published by the Free Software Foundation.
> + */
> +
> +#include <nft.h>
> +#include <profiling.h>
> +
> +#include <signal.h>
> +#include <stdio.h>
> +
> +static void termhandler(int signo)
> +{
> + switch (signo) {
> + case SIGTERM:
> + exit(143);
> + case SIGINT:
> + exit(130);
Unfortunately I can't find exit(3) in the list of async-signal safe
functions, so I have to assume this isn't allowed.
From a quick glance, I would suggest to either use self-pipe-trick, or,
given nft is linux specific anyway, use signalfd(2) instead of a
traditional handler; then, stuff the fd into mnl_nft_event_listener
select().
Sorry, I did not think of this earlier. If I'm wrong and this is safe,
next prev parent reply other threads:[~2026-02-12 0:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 20:14 [nft PATCH v3] configure: Implement --enable-profiling option Phil Sutter
2026-02-12 0:08 ` Florian Westphal [this message]
2026-02-12 0:19 ` Florian Westphal
2026-02-12 20:49 ` Phil Sutter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aY0Z63yPjQoXYp9b@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.