-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
Description
If we take the minimal following c program:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <time.h>
int main() {
int test = fork();
if (test == 0) {
printf("Exiting parent\n");
return 0;
} else if (test > 0) {
struct timespec test5 = {1, 0};
int fd = open("/tmp/test10", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
nanosleep(&test5, NULL);
write(fd, "test", 4);
write(fd, "test", 4);
close(fd);
}
printf("Exiting fork\n");
exit(0);
return 0;
}
and try to execute it with lit using the internal shell with a test file like the following:
// RUN: %clang %S/test.c -o %t.exe
// RUN: %t.exe
lit will end up hanging in a Popen.communicate()
call for unknown reasons. A workaround for now is to just invoke the test with bash and have a wait call:
// RUN: %clang %S/test.c -o %t.exe
// RUN: bash -c "%t.exe; wait"