[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / lsan / TestCases / Linux / fork_and_leak.cpp
blob1f54d296e93f4a214382956fed7a6700c59d39c8
1 // Test that leaks detected after forking without exec().
2 // RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s
4 /// Fails on clang-cmake-aarch64-full (glibc 2.27-3ubuntu1.4).
5 // UNSUPPORTED: aarch64
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <sys/wait.h>
10 #include <unistd.h>
12 int main() {
13 pid_t pid = fork();
14 assert(pid >= 0);
15 if (pid > 0) {
16 int status = 0;
17 waitpid(pid, &status, 0);
18 assert(WIFEXITED(status));
19 return WEXITSTATUS(status);
20 } else {
21 for (int i = 0; i < 10; ++i)
22 malloc(1337);
23 // CHECK: LeakSanitizer: detected memory leaks
25 return 0;