*sigpause hanging on 8.x+
Kostik Belousov
kostikbel at gmail.com
Sun Jul 11 21:08:48 UTC 2010
On Sun, Jul 11, 2010 at 12:39:39PM -0700, Garrett Cooper wrote:
> So, long story short... I've basically ported the open posix testsuite
> to FreeBSD, and one of the tests tests out sigpause. Unfortunately the
> sucker hangs on my dev box at home.
>
> I've written a short testcase that demonstrates this. It prints out:
>
> $ ~/test_sigpause
> 0
>
> And proceeds to be unresponsive to signals (except SIGSTOP / SIGKILL,
> as expected).
>
> When I monkey around with libc's compat4.3 stuff a bit, this is what comes up:
>
> $ env LD_LIBRARY_PATH=$PWD:/usr/src/lib/libc/../libthr ~/test_sigpause
> 0
> before sigemptyset
> before _sigsuspend
>
> So it's getting stuck after calling _sigsuspend.
>
> I tried the same thing on a i386 8-STABLE VM and it hangs as well.
>
> I tried applying similar printfs in libthr but it's not hitting that
> code at all (it's now responding to SIGTERM though, which is
> interesting, but not too interesting to me).
>
> I also wrote similar code that exercised the functionality in
> sigsuspend, by calling sigprocmask beforehand, and it works.
>
> Thoughts?
>
> -Garrett
>
> Dev machine:
> FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #1
> r206173:209901M: Sun Jul 11 04:18:42 PDT 2010
> root@:/usr/obj/usr/src/sys/BAYONETTA amd64
> VM:
> FreeBSD starr-bastion.localdomain 8.0-STABLE FreeBSD 8.0-STABLE #0
> r207913: Tue May 11 06:21:57 UTC 2010
> root at starr-bastion.localdomain:/usr/obj/usr/src/sys/GENERIC i386
>
> Index: compat-43/sigcompat.c
> ===================================================================
> --- compat-43/sigcompat.c (revision 206173)
> +++ compat-43/sigcompat.c (working copy)
> @@ -36,6 +36,7 @@
> #include "namespace.h"
> #include <sys/param.h>
> #include <signal.h>
> +#include <stdio.h>
> #include <string.h>
> #include "un-namespace.h"
> #include "libc_private.h"
> @@ -102,7 +103,9 @@
> {
> sigset_t set;
>
> + printf("before sigemptyset\n");
> sigemptyset(&set);
> + printf("before _sigsuspend\n");
> set.__bits[0] = mask;
> return (_sigsuspend(&set));
> }
> @@ -111,10 +114,16 @@
> xsi_sigpause(int sig)
> {
> sigset_t set;
> + int rc;
>
> + printf("before sigemptyset\n");
> sigemptyset(&set);
> + printf("before sigaddset\n");
> sigaddset(&set, sig);
> - return (_sigsuspend(&set));
> + printf("before _sigsuspend\n");
> + rc = (_sigsuspend(&set));
> + printf("after _sigsuspend\n");
> + return rc;
> }
>
> int
>
> $ cat ~/test_sigpause.c
> #include <signal.h>
> #include <stdio.h>
>
> int
> main (void)
> {
> printf("0\n");
> fflush(stdout);
> (void) sigpause(1);
> return 0;
> }
> $ cat ~/test_sigsuspend.c
> #include <err.h>
> #include <signal.h>
>
> int
> main (void)
> {
> sigset_t oset;
> sigset_t nset;
> if (sigprocmask(1, &nset, &oset) == -1)
> err(1, "sigprocmask(-1, &nset, &oset)");
> if (sigprocmask(-1, &nset, &oset) == -1)
> err(1, "sigprocmask(-1, &nset, &oset)");
> return (sigsuspend(&nset));
> }
It seems I got a sigmask for sigpause inside the xsi_sigpause() backward.
On the other hand, I do not understand what is your issue with sigpause().
diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c
index c3ba30a..bab9d5c 100644
--- a/lib/libc/compat-43/sigcompat.c
+++ b/lib/libc/compat-43/sigcompat.c
@@ -111,9 +111,12 @@ int
xsi_sigpause(int sig)
{
sigset_t set;
+ int error;
- sigemptyset(&set);
- sigaddset(&set, sig);
+ error = _sigprocmask(SIG_BLOCK, NULL, &set);
+ if (error != 0)
+ return (error);
+ sigdelset(&set, sig);
return (_sigsuspend(&set));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20100711/04635343/attachment.pgp
More information about the freebsd-hackers
mailing list