• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test that leaks detected after forking without exec().
2 // RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s
3 
4 #include <assert.h>
5 #include <stdlib.h>
6 #include <sys/wait.h>
7 #include <unistd.h>
8 
main()9 int main() {
10   pid_t pid = fork();
11   assert(pid >= 0);
12   if (pid > 0) {
13     int status = 0;
14     waitpid(pid, &status, 0);
15     assert(WIFEXITED(status));
16     return WEXITSTATUS(status);
17   } else {
18     malloc(1337);
19     // CHECK: LeakSanitizer: detected memory leaks
20   }
21   return 0;
22 }
23 
24