According to the Linux kernel code, we know that the sigqueue is
allocated and queue the signal to it's list by the system call
rt_sigqueueinfo(2) which called by sigqueue(3) in this test code.
Meanwhile, if the signal is queued, it increase the user's sigpending
field. Then if it going to queue another signal, it read the rlimit of
the sigpending from the task's signal->rlim[] member and compare with
the user's current sigpending number.
So, it's the issue. The user who is running this code may have other
pending signals before this, and actually it does.

After the latest change Peter removed the sigaction, the test case goes
to Segmentfault:

rt_sigqueueinfo(13632, SIGRT_2, {si_signo=SIGRT_2, si_code=SI_QUEUE, 
si_pid=13632, si_uid=0, si_value={int=0, ptr=0x3e00000000}}) = -1 EAGAIN 
(Resource temporarily unavailable)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7fab262ad000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

Sure, sigaction is unneeded, but the *root* user always has some signal
in the queue, which caused the test case goes to fail.

This patch change the running user to *nobody*, which has no signal in its
queue normally.


My latest patch for this case is about to calculate the signal in the user's
queue, but it only effect on Linux. So, I do this patch.

Signed-off-by: Wanlong Gao <[email protected]>
---
 .../conformance/interfaces/sigqueue/9-1.c          |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/sigqueue/9-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/sigqueue/9-1.c
index e9a994f..0b31a9f 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigqueue/9-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigqueue/9-1.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <pwd.h>
 #include "posixtest.h"
 
 int main(void)
@@ -41,7 +42,22 @@ int main(void)
        union sigval value;
 
        value.sival_int = 0;    /* 0 is just an arbitrary value */
-       pid = getpid();
+
+       /*
+        * Do a best effort at trying to get root demoted to "nobody" for the
+        * duration of the test.
+        */
+       if (getuid() == 0) {
+
+               struct passwd *pwd;
+
+               pwd = getpwnam("nobody");
+               if (pwd != NULL) {
+                       setgid(pwd->pw_gid);
+                       setuid(pwd->pw_uid);
+               }
+
+       }
 
        sighold(SIGTOTEST);
 
-- 
1.7.6


------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to