All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] openposix/twoptimers.c: Use other signal instead of SIGALRM
@ 2020-03-18  9:16 Yang Xu
  2020-03-18 10:00 ` Xiao Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Xu @ 2020-03-18  9:16 UTC (permalink / raw)
  To: ltp

Currently, run this case failed as below:

Got it!  Child
Alarm clock

Parent process doesn't get SIGALRM siganl by using sigwait. It
seems SIGALRM siganl is handled by system but not user.

From timer_create man-page, it said "
Specifying  sevp as NULL is equivalent to specifying a pointer to
a sigevent structure in which sigev_notify is SIGEV_SIGNAL, sigev_signo
is SIGALRM, and sigev_value.sival_int is the timer ID".

I think this is the reason. So use SIGILL signal to avoid system caught.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 .../functional/timers/timers/twoptimers.c                     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
index 84bea3f0a..7e1648d5b 100644
--- a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
+++ b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
@@ -92,13 +92,13 @@ int main(int argc, char *argv[])
 			return PTS_UNRESOLVED;
 		}
 
-		if (sigaddset(&set, SIGALRM) == -1) {
+		if (sigaddset(&set, SIGILL) == -1) {
 			perror("sigaddset() failed\n");
 			return PTS_UNRESOLVED;
 		}
 
 		ev.sigev_notify = SIGEV_SIGNAL;
-		ev.sigev_signo = SIGALRM;
+		ev.sigev_signo = SIGILL;
 		if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
 			perror("timer_create() did not return success\n");
 			return PTS_UNRESOLVED;
-- 
2.18.1




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

* [LTP] [PATCH] openposix/twoptimers.c: Use other signal instead of SIGALRM
  2020-03-18  9:16 [LTP] [PATCH] openposix/twoptimers.c: Use other signal instead of SIGALRM Yang Xu
@ 2020-03-18 10:00 ` Xiao Yang
  2020-03-20  4:27   ` Yang Xu
  2020-03-25  5:07   ` [LTP] [PATCH v2] openposix/twoptimers: handle signal correctly Yang Xu
  0 siblings, 2 replies; 5+ messages in thread
From: Xiao Yang @ 2020-03-18 10:00 UTC (permalink / raw)
  To: ltp

On 2020/3/18 17:16, Yang Xu wrote:
> Currently, run this case failed as below:
>
> Got it!  Child
> Alarm clock
>
> Parent process doesn't get SIGALRM siganl by using sigwait. It
> seems SIGALRM siganl is handled by system but not user.
>
>> From timer_create man-page, it said "
> Specifying  sevp as NULL is equivalent to specifying a pointer to
> a sigevent structure in which sigev_notify is SIGEV_SIGNAL, sigev_signo
> is SIGALRM, and sigev_value.sival_int is the timer ID".
>
> I think this is the reason. So use SIGILL signal to avoid system caught.
Hi Xu,

I don't like the fix.  You don't figure out the root cause of issue and 
just bypass it.(User can catch SIGALRM by default usually).

Perhaps, you need to reset the behavior of SIGALRM to default if it is 
not default.

Thanks,
Xiao Yang
> Signed-off-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
> ---
>   .../functional/timers/timers/twoptimers.c                     | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
> index 84bea3f0a..7e1648d5b 100644
> --- a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
> +++ b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
> @@ -92,13 +92,13 @@ int main(int argc, char *argv[])
>   			return PTS_UNRESOLVED;
>   		}
>
> -		if (sigaddset(&set, SIGALRM) == -1) {
> +		if (sigaddset(&set, SIGILL) == -1) {
>   			perror("sigaddset() failed\n");
>   			return PTS_UNRESOLVED;
>   		}
>
>   		ev.sigev_notify = SIGEV_SIGNAL;
> -		ev.sigev_signo = SIGALRM;
> +		ev.sigev_signo = SIGILL;
>   		if (timer_create(CLOCK_REALTIME,&ev,&tid) != 0) {
>   			perror("timer_create() did not return success\n");
>   			return PTS_UNRESOLVED;




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

* [LTP] [PATCH] openposix/twoptimers.c: Use other signal instead of SIGALRM
  2020-03-18 10:00 ` Xiao Yang
@ 2020-03-20  4:27   ` Yang Xu
  2020-03-25  5:07   ` [LTP] [PATCH v2] openposix/twoptimers: handle signal correctly Yang Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Yang Xu @ 2020-03-20  4:27 UTC (permalink / raw)
  To: ltp

Hi Xiao

> On 2020/3/18 17:16, Yang Xu wrote:
>> Currently, run this case failed as below:
>>
>> Got it!? Child
>> Alarm clock
>>
>> Parent process doesn't get SIGALRM siganl by using sigwait. It
>> seems SIGALRM siganl is handled by system but not user.
>>
>>> From timer_create man-page, it said "
>> Specifying? sevp as NULL is equivalent to specifying a pointer to
>> a sigevent structure in which sigev_notify is SIGEV_SIGNAL, sigev_signo
>> is SIGALRM, and sigev_value.sival_int is the timer ID".
>>
>> I think this is the reason. So use SIGILL signal to avoid system caught.
> Hi Xu,
> 
> I don't like the fix.? You don't figure out the root cause of issue and 
> just bypass it.(User can catch SIGALRM by default usually).
Sorry for this.
Yes. But user usually will install customized singal handler for SIGALRM 
by using sigaction function. On multi threads program, user will set 
SIGALRM signal into signal mask by using sigprocmask, so it can ensure 
current thread can get this signal from pending list.

So I plan to fix this bug as below:

--- a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
+++ b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
@@ -50,7 +50,10 @@ int main(int argc, char *argv[])
                         perror("sigaddset() failed\n");
                         return PTS_UNRESOLVED;
                 }
-
+               if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
+                       perror("sigprocmask() failed\n");
+                       return PTS_UNRESOLVED;
+               }
                 ev.sigev_notify = SIGEV_SIGNAL;
                 ev.sigev_signo = SIGABRT;
                 if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
@@ -73,8 +76,10 @@ int main(int argc, char *argv[])
                         perror("sigwait() failed\n");
                         return PTS_UNRESOLVED;
                 }
-               printf("Got it!  Child\n");
-
+               if (sig == SIGABRT)
+                       printf("Got it!  Child\n");
+               else
+                       printf("Got another signal! Child\n");
                 sleep(LONGTIME);
                 return CHILDPASS;
         } else {
@@ -96,6 +101,10 @@ int main(int argc, char *argv[])
                         perror("sigaddset() failed\n");
                         return PTS_UNRESOLVED;
                 }
+               if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
+                       perror("sigprocmask() failed\n");
+                       return PTS_UNRESOLVED;
+                }

                 ev.sigev_notify = SIGEV_SIGNAL;
                 ev.sigev_signo = SIGALRM;
@@ -119,8 +128,10 @@ int main(int argc, char *argv[])
                         perror("sigwait() failed\n");
                         return PTS_UNRESOLVED;
                 }
-               printf("Got it!  Parent\n");
-
+               if (sig == SIGALRM)
+                       printf("Got it!  Parent\n");
+               else
+                       printf("Got another signal! Parent\n");

How about this?

Best Regards
Yang Xu
> 
> Perhaps, you need to reset the behavior of SIGALRM to default if it is 
> not default..
> 
> Thanks,
> Xiao Yang
>> Signed-off-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>> ---
>> ? .../functional/timers/timers/twoptimers.c???????????????????? | 4 ++--
>> ? 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git 
>> a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c 
>> b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
>> index 84bea3f0a..7e1648d5b 100644
>> --- 
>> a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
>> +++ 
>> b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
>> @@ -92,13 +92,13 @@ int main(int argc, char *argv[])
>> ????????????? return PTS_UNRESOLVED;
>> ????????? }
>>
>> -??????? if (sigaddset(&set, SIGALRM) == -1) {
>> +??????? if (sigaddset(&set, SIGILL) == -1) {
>> ????????????? perror("sigaddset() failed\n");
>> ????????????? return PTS_UNRESOLVED;
>> ????????? }
>>
>> ????????? ev.sigev_notify = SIGEV_SIGNAL;
>> -??????? ev.sigev_signo = SIGALRM;
>> +??????? ev.sigev_signo = SIGILL;
>> ????????? if (timer_create(CLOCK_REALTIME,&ev,&tid) != 0) {
>> ????????????? perror("timer_create() did not return success\n");
>> ????????????? return PTS_UNRESOLVED;
> 



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

* [LTP] [PATCH v2] openposix/twoptimers: handle signal correctly
  2020-03-18 10:00 ` Xiao Yang
  2020-03-20  4:27   ` Yang Xu
@ 2020-03-25  5:07   ` Yang Xu
  2020-05-05 14:57     ` Cyril Hrubis
  1 sibling, 1 reply; 5+ messages in thread
From: Yang Xu @ 2020-03-25  5:07 UTC (permalink / raw)
  To: ltp

Usually, when we want to get a signal to handle, we should install
customized signal handler function by using sigation. The other way
is to block this signal and use sigwait() to get the signal from its
pending list. Use sigprocmask(SIGBLOCK, &set, NULL) to make sure we
can get SIGABRT/SIGALRM signal.

Test this case on 2.6.18-398.el5, it doesn't get any signal.
higer versions than this only get SIGABRT signal.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 .../functional/timers/timers/twoptimers.c     | 20 ++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
index 84bea3f0a..b2657539c 100644
--- a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
+++ b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
@@ -51,6 +51,10 @@ int main(int argc, char *argv[])
 			return PTS_UNRESOLVED;
 		}
 
+		if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
+			perror("sigprocmask() failed\n");
+			return PTS_UNRESOLVED;
+		}
 		ev.sigev_notify = SIGEV_SIGNAL;
 		ev.sigev_signo = SIGABRT;
 		if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
@@ -73,8 +77,10 @@ int main(int argc, char *argv[])
 			perror("sigwait() failed\n");
 			return PTS_UNRESOLVED;
 		}
-		printf("Got it!  Child\n");
-
+		if (sig == SIGABRT)
+			printf("Got it! Child\n");
+		else
+			printf("Got another signal! Child\n");
 		sleep(LONGTIME);
 		return CHILDPASS;
 	} else {
@@ -97,6 +103,11 @@ int main(int argc, char *argv[])
 			return PTS_UNRESOLVED;
 		}
 
+		if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
+			perror("sigaprocmask() failed\n");
+			return PTS_UNRESOLVED;
+		}
+
 		ev.sigev_notify = SIGEV_SIGNAL;
 		ev.sigev_signo = SIGALRM;
 		if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
@@ -119,7 +130,10 @@ int main(int argc, char *argv[])
 			perror("sigwait() failed\n");
 			return PTS_UNRESOLVED;
 		}
-		printf("Got it!  Parent\n");
+		if (sig == SIGALRM)
+			printf("Got it! Parent\n");
+		else
+			printf("Got another signal! Parent\n");
 
 		if (wait(&i) == -1) {
 			perror("Error waiting for child to exit\n");
-- 
2.23.0




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

* [LTP] [PATCH v2] openposix/twoptimers: handle signal correctly
  2020-03-25  5:07   ` [LTP] [PATCH v2] openposix/twoptimers: handle signal correctly Yang Xu
@ 2020-05-05 14:57     ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2020-05-05 14:57 UTC (permalink / raw)
  To: ltp

Hi!
I've also changed the code so that the test fails if we got wrong signal
and removed the useless sleep() in the child and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2020-05-05 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18  9:16 [LTP] [PATCH] openposix/twoptimers.c: Use other signal instead of SIGALRM Yang Xu
2020-03-18 10:00 ` Xiao Yang
2020-03-20  4:27   ` Yang Xu
2020-03-25  5:07   ` [LTP] [PATCH v2] openposix/twoptimers: handle signal correctly Yang Xu
2020-05-05 14:57     ` Cyril Hrubis

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.