All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH 1/4] configure: Implement --enable-profiling option
Date: Thu, 5 Feb 2026 02:29:02 +0100	[thread overview]
Message-ID: <aYPyXsiChD6WfcBB@chamomile> (raw)
In-Reply-To: <20260127222916.31806-2-phil@nwl.cc>

On Tue, Jan 27, 2026 at 11:29:13PM +0100, Phil Sutter wrote:
> diff --git a/src/main.c b/src/main.c
> index 29b0533dee7c9..bdcf8ab3c304b 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -16,6 +16,7 @@
>  #include <errno.h>
>  #include <getopt.h>
>  #include <fcntl.h>
> +#include <signal.h>
>  #include <sys/types.h>
>  
>  #include <nftables/libnftables.h>
> @@ -360,6 +361,33 @@ static bool nft_options_check(int argc, char * const argv[])
>  	return true;
>  }
>  
> +#ifdef BUILD_PROFILING
> +static void termhandler(int signo)
> +{
> +	switch (signo) {
> +	case SIGTERM:
> +		exit(143);
> +	case SIGINT:
> +		exit(130);
> +	}
> +}
> +
> +static void setup_sighandler(void)
> +{
> +	struct sigaction act = {
> +		.sa_handler = termhandler,
> +	};
> +
> +	if (sigaction(SIGTERM, &act, NULL) == -1 ||
> +	    sigaction(SIGINT, &act, NULL) == -1) {
> +		perror("sigaction");
> +		exit(1);
> +	}
> +}
> +#else
> +static void setup_sighandler(void) { /* empty */ }
> +#endif

Nitpick: This is small, but please add it to src/profile.c, to make
extending it future proof and reduce ifdef pollution a bit.

With a include/profile.h also you can define the empty stub for
setup_sighandler() when !BUILD_PROFILING.

Thanks

> +
>  int main(int argc, char * const *argv)
>  {
>  	const struct option *options = get_options();
> @@ -375,6 +403,8 @@ int main(int argc, char * const *argv)
>  	if (getuid() != geteuid())
>  		_exit(111);
>  
> +	setup_sighandler();
> +
>  	if (!nft_options_check(argc, argv))
>  		exit(EXIT_FAILURE);
>  
> -- 
> 2.51.0
> 

  reply	other threads:[~2026-02-05  1:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 22:29 [nft PATCH 0/4] Inspect and improve test suite code coverage Phil Sutter
2026-01-27 22:29 ` [nft PATCH 1/4] configure: Implement --enable-profiling option Phil Sutter
2026-02-05  1:29   ` Pablo Neira Ayuso [this message]
2026-01-27 22:29 ` [nft PATCH 2/4] tests: shell: Add a simple test for nftrace Phil Sutter
2026-01-27 22:29 ` [nft PATCH 3/4] xt: Print comment match data as well Phil Sutter
2026-02-05  1:35   ` Pablo Neira Ayuso
2026-02-05 13:29     ` Phil Sutter
2026-01-27 22:29 ` [nft PATCH 4/4] tests: shell: Add a basic test for src/xt.c Phil Sutter
2026-02-05  1:35 ` [nft PATCH 0/4] Inspect and improve test suite code coverage Pablo Neira Ayuso
2026-02-05 13:30   ` Phil Sutter
2026-02-05 15:21 ` 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=aYPyXsiChD6WfcBB@chamomile \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.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.