[CRIU] [PATCH] zdtm: Use SIGWINCH instead of SIGTRAP in pthread01
Andrew Vagin
avagin at parallels.com
Thu Nov 22 13:29:22 EST 2012
On Mon, Nov 19, 2012 at 04:59:01PM +0400, Cyrill Gorcunov wrote:
> Otherwise test with -d option get fail (this is because
> SIGTRAP get cleared by our parasizte engine).
>
> The proper fix most likely will require kernel patching
> or redesign of parasite code. Meanwhile to make test
> working we switch to the signal which just known to work.
I agree with this sentence.
>
> Also I've fixed a couple of s/sigprocmask/pthread_sigmask/
> and reworked the procedure of showing the signals mask to
> more readable format.
So this patch should be splitted on three;)
* switch to the signal which just known to work
* s/sigprocmask/pthread_sigmask/
* showing the signals mask to more readable format
>
> Reported-by: Andrey Vagin <avagin at openvz.org>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> test/zdtm/live/static/pthread01.c | 48 +++++++++++++++++++++++++++++-------
> 1 files changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/test/zdtm/live/static/pthread01.c b/test/zdtm/live/static/pthread01.c
> index 28d42b4..814df1f 100644
> --- a/test/zdtm/live/static/pthread01.c
> +++ b/test/zdtm/live/static/pthread01.c
> @@ -27,17 +27,38 @@ static __thread struct tls_data_s {
> static task_waiter_t t1;
> static task_waiter_t t2;
>
> -static void show_sigset(const sigset_t *s)
> +static char *decode_signal(const sigset_t *s, char *buf)
> {
> - const char *p = (void *)s;
> - char buf[1024];
> - size_t i;
> + buf[0] = '\0';
> +
> +#define COLLECT(sig) \
> + do { \
> + if ((long)s->__val[0] & (long)sigmask(sig)) \
> + strcat(buf, #sig " "); \
> + } while (0)
> +
> + COLLECT(SIGHUP); COLLECT(SIGINT); COLLECT(SIGQUIT); COLLECT(SIGILL); COLLECT(SIGTRAP);
> + COLLECT(SIGABRT); COLLECT(SIGIOT); COLLECT(SIGBUS); COLLECT(SIGFPE); COLLECT(SIGKILL);
> + COLLECT(SIGUSR1); COLLECT(SIGSEGV); COLLECT(SIGUSR2); COLLECT(SIGPIPE); COLLECT(SIGALRM);
> + COLLECT(SIGTERM); COLLECT(SIGSTKFLT); COLLECT(SIGCHLD); COLLECT(SIGCONT); COLLECT(SIGSTOP);
> + COLLECT(SIGTSTP); COLLECT(SIGTTIN); COLLECT(SIGTTOU); COLLECT(SIGURG); COLLECT(SIGXCPU);
> + COLLECT(SIGXFSZ); COLLECT(SIGVTALRM); COLLECT(SIGPROF); COLLECT(SIGWINCH); COLLECT(SIGIO);
> + COLLECT(SIGPOLL); COLLECT(SIGPWR); COLLECT(SIGSYS); COLLECT(SIGUNUSED);
> +#undef COLLECT
I don't like this code. For me a hex number is better for reading than a
set of SIG*... We need to show only u64.
> +
> + return buf;
> +}
> +
> +static void __show_sigset(int line, const sigset_t *s)
> +{
> + char buf[sizeof(sigset_t) * 2 + 1] = { };
>
> - for (i = 0; i < sizeof(*s); i++)
> - sprintf(&buf[i * 2], "%02x", p[i]);
> - test_msg("sigset: %s\n", buf);
> + decode_signal(s, buf);
> + test_msg("sigset at %4d: %s\n", line, buf);
> }
>
> +#define show_sigset(set) __show_sigset(__LINE__, set)
> +
> static void *ch_thread_2(void *arg)
> {
> char __tls_data[sizeof(tls_data.rand_string)] = "XM5o:?B*[a";
> @@ -48,11 +69,14 @@ static void *ch_thread_2(void *arg)
> memcpy(tls_data.rand_string, __tls_data, sizeof(tls_data.rand_string));
>
> sigemptyset(&blk_sigset);
> - sigprocmask(SIG_SETMASK, NULL, &blk_sigset);
> + pthread_sigmask(SIG_SETMASK, NULL, &blk_sigset);
> sigaddset(&blk_sigset, SIGFPE);
> pthread_sigmask(SIG_SETMASK, &blk_sigset, NULL);
> memcpy(&tls_data.blk_sigset, &blk_sigset, sizeof(tls_data.blk_sigset));
>
> + show_sigset(&blk_sigset);
> + show_sigset(&tls_data.blk_sigset);
> +
> task_waiter_complete(&t2, 1);
> task_waiter_wait4(&t2, 2);
>
> @@ -91,11 +115,15 @@ static void *ch_thread_1(void *arg)
> memcpy(tls_data.rand_string, __tls_data, sizeof(tls_data.rand_string));
>
> sigemptyset(&blk_sigset);
> - sigprocmask(SIG_SETMASK, NULL, &blk_sigset);
> - sigaddset(&blk_sigset, SIGTRAP);
> + pthread_sigmask(SIG_SETMASK, NULL, &blk_sigset);
> + sigaddset(&blk_sigset, SIGWINCH);
> + sigaddset(&blk_sigset, SIGALRM);
> pthread_sigmask(SIG_SETMASK, &blk_sigset, NULL);
> memcpy(&tls_data.blk_sigset, &blk_sigset, sizeof(tls_data.blk_sigset));
>
> + show_sigset(&blk_sigset);
> + show_sigset(&tls_data.blk_sigset);
> +
> task_waiter_complete(&t1, 1);
> task_waiter_wait4(&t1, 2);
>
> --
> 1.7.7.6
>
More information about the CRIU
mailing list