[PATCH 1/2] posix: Correctly enable/disable cancellation on Linux posix_spawn
Florian Weimer
fw@deneb.enyo.de
Tue Sep 20 19:24:00 GMT 2016
* 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.
More information about the Libc-alpha
mailing list