glibc/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/reproducer.c
Sergey Kolosov ab4bc8a24e Extend the test coverage
Move some of the RHEL QE testcases upstream to Fedora.
2022-05-31 09:29:27 +02:00

39 lines
535 B
C

#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#define LOOPS 1000
uid_t uid;
void *subthread(void *dummy)
{
setuid(uid);
}
int main(void)
{
pthread_t tid[LOOPS];
int i, ret;
uid = getuid();
for(i=0; i < LOOPS; i++) {
ret = pthread_create(&tid[i], NULL, &subthread, NULL);
if(ret != 0) {
perror("pthread_create");
return 1;
}
}
for(i=0; i < LOOPS; i++) {
ret = pthread_join(tid[i], NULL);
if(ret != 0) {
perror("pthread_join");
}
}
return 0;
}