Message ID | 20221101112621.20031-1-rpalethorpe@suse.com |
---|---|
State | Accepted |
Headers | show |
Series | pidns12: Avoid write in sig handler | expand |
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; > }
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; }
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(-)