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



On 20/09/2016 16:24, Florian Weimer wrote:
> * 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).
> 

Ack, I will change to xpthread_barrier_wait.

>> +  /* 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?

Not in this test because the idea is to check if posix_spawn acts or not
on a pending cancellation, not if an asynchronous cancellation cancels the
thread while the thread executes posix_spawn.

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

Ack.

> 
>> +  if (pthread_join (th, &r) != 0)
> 
> xpthread_join.
> 

Ack.


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