Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / posix_spawn.c
blobea58b92af6097d0e3d3a72e27d2a51d775bd6bb9
1 // RUN: %clang %s -o %t && %run %t 2>&1 | FileCheck %s
2 //
3 // Older versions of Android do not have certain posix_spawn* functions.
4 // UNSUPPORTED: android
6 #include <assert.h>
7 #include <spawn.h>
8 #include <stdio.h>
9 #include <sys/wait.h>
11 int main(int argc, char **argv) {
12 if (argc > 1) {
13 // CHECK: SPAWNED
14 // CHECK: SPAWNED
15 printf("SPAWNED\n");
16 return 0;
19 posix_spawnattr_t attr = {0};
20 posix_spawn_file_actions_t file_actions = {0};
22 char *const args[] = {
23 argv[0], "2", "3", "4", "2", "3", "4", "2", "3", "4",
24 "2", "3", "4", "2", "3", "4", "2", "3", "4", NULL,
26 char *const env[] = {
27 "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B",
28 "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", NULL,
31 pid_t pid;
32 int s = posix_spawn(&pid, argv[0], &file_actions, &attr, args, env);
33 assert(!s);
35 waitpid(pid, &s, WUNTRACED | WCONTINUED);
37 s = posix_spawnp(&pid, argv[0], &file_actions, &attr, args, env);
38 assert(!s);
40 waitpid(pid, &s, WUNTRACED | WCONTINUED);
41 return 0;