public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] pidns12: Avoid write in sig handler
@ 2022-11-01 11:26 Richard Palethorpe via ltp
  2022-11-14 11:34 ` Richard Palethorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Palethorpe via ltp @ 2022-11-01 11:26 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

It is best to avoid doing any kind of unecessary work in a signal
handler.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Cc: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/containers/pidns/pidns12.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/containers/pidns/pidns12.c b/testcases/kernel/containers/pidns/pidns12.c
index 65e2a0836..0e6b17142 100644
--- a/testcases/kernel/containers/pidns/pidns12.c
+++ b/testcases/kernel/containers/pidns/pidns12.c
@@ -18,9 +18,11 @@
 #include "tst_test.h"
 #include "lapi/namespaces_constants.h"
 
+static volatile pid_t sig_pid = -1;
+
 static void child_signal_handler(LTP_ATTRIBUTE_UNUSED int sig, siginfo_t *si, LTP_ATTRIBUTE_UNUSED void *unused)
 {
-	TST_EXP_EQ_LI(si->si_pid, 0);
+	sig_pid = si->si_pid;
 }
 
 static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
@@ -38,6 +40,8 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
 
 	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
+	TST_EXP_EQ_LI(sig_pid, 0);
+
 	return 0;
 }
 
-- 
2.38.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH] pidns12: Avoid write in sig handler
  2022-11-01 11:26 [LTP] [PATCH] pidns12: Avoid write in sig handler Richard Palethorpe via ltp
@ 2022-11-14 11:34 ` Richard Palethorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Palethorpe @ 2022-11-14 11:34 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hello,

Richard Palethorpe <rpalethorpe@suse.com> writes:

> It is best to avoid doing any kind of unecessary work in a signal
> handler.

No review after 2 weeks. Merged!

>
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> Cc: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
>  testcases/kernel/containers/pidns/pidns12.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/containers/pidns/pidns12.c b/testcases/kernel/containers/pidns/pidns12.c
> index 65e2a0836..0e6b17142 100644
> --- a/testcases/kernel/containers/pidns/pidns12.c
> +++ b/testcases/kernel/containers/pidns/pidns12.c
> @@ -18,9 +18,11 @@
>  #include "tst_test.h"
>  #include "lapi/namespaces_constants.h"
>  
> +static volatile pid_t sig_pid = -1;
> +
>  static void child_signal_handler(LTP_ATTRIBUTE_UNUSED int sig, siginfo_t *si, LTP_ATTRIBUTE_UNUSED void *unused)
>  {
> -	TST_EXP_EQ_LI(si->si_pid, 0);
> +	sig_pid = si->si_pid;
>  }
>  
>  static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
> @@ -38,6 +40,8 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
>  
>  	TST_CHECKPOINT_WAKE_AND_WAIT(0);
>  
> +	TST_EXP_EQ_LI(sig_pid, 0);
> +
>  	return 0;
>  }


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-14 11:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-01 11:26 [LTP] [PATCH] pidns12: Avoid write in sig handler Richard Palethorpe via ltp
2022-11-14 11:34 ` Richard Palethorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox