This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] posix: Correctly enable/disable cancellation on Linux posix_spawn
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 20 Sep 2016 21:24:41 +0200
- Subject: Re: [PATCH 1/2] posix: Correctly enable/disable cancellation on Linux posix_spawn
- Authentication-results: sourceware.org; auth=none
- References: <1473879370-6731-1-git-send-email-adhemerval.zanella@linaro.org>
* Adhemerval Zanella:
> + int e = pthread_barrier_wait (&b);
> + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
> + {
> + puts ("error: pthread_barrier_wait failed");
> + exit (1);
> + }
We have xpthread_barrier_wait now (also below).
> + /* The test basically pipes a 'echo $$' created by a thread with a
> + cancellation pending. It then checks if the thread is not
> + cancelled, the process is created, and if the output is the expected
> + one (the process pid). */
Don't you have to try this multiple times, to see if you can hit the
race?
> +
> + if (pipe (targ.fd) != 0)
> + {
> + puts ("error: pipe failed");
> + exit (1);
> + }
> +
> + /* Not interested in knowing when the pipe is closed. */
> + if (sigignore (SIGPIPE) != 0)
> + {
> + puts ("error: sigignore failed");
> + exit (1);
> + }
> +
> + if (pthread_barrier_init (&b, NULL, 2) != 0)
> + {
> + puts ("error: pthread_barrier_init failed");
> + exit (1);
> + }
> +
> + pthread_t th;
> + if (pthread_create (&th, NULL, tf, &targ) != 0)
xpthread_create.
> + if (pthread_join (th, &r) != 0)
xpthread_join.