Debian Codegraph @

compiler-rt/test/sanitizer_common/TestCases/Linux/setuid.c

raw
1 // RUN: %clang -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 //
3 // setuid(0) hangs on powerpc64 big endian. When this is fixed remove
4 // the unsupported flag.
5 // https://llvm.org/bugs/show_bug.cgi?id=25799
6 //
7 // UNSUPPORTED: target=powerpc64-unknown-linux-gnu{{.*}}
8
9 #include <pthread.h>
10 #include <stdio.h>
11 #include <sys/types.h>
12 #include <unistd.h>
13
14 // Setuid call used to hang because the new thread did not handle
15 // SIGSETXID signal. Note that we don't care whether setuid call succeeds
16 // or not.
17
18 static void *thread(void *arg) {
19 (void)arg;
20 sleep(1);
21 return 0;
22 }
23
24 int main() {
25 // Create another thread just for completeness of the picture.
26 pthread_t th;
27 pthread_create(&th, 0, thread, 0);
28 setuid(0);
29 pthread_join(th, 0);
30 fprintf(stderr, "DONE\n");
31 return 0;
32 }
33
34 // CHECK: DONE