// Test that leaks detected after forking without exec().
// RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s

#include <assert.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>

int main() {
  pid_t pid = fork();
  assert(pid >= 0);
  if (pid > 0) {
    int status = 0;
    waitpid(pid, &status, 0);
    assert(WIFEXITED(status));
    return WEXITSTATUS(status);
  } else {
    malloc(1337);
    // CHECK: LeakSanitizer: detected memory leaks
  }
  return 0;
}


Check that leak sanitizer works in the forked process
[lsan] Check that leak sanitizer works in the forked process

Regression test for PR38698

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@340769 91177308-0d34-0410-b5e6-96231b3b80d8
