This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] posix: Correctly enable/disable cancellation on Linux posix_spawn


* 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]