[all-commits] [llvm/llvm-project] 5a7f9a: [flang] use setsid to assign the child to prevent ...

Yi Wu via All-commits all-commits at lists.llvm.org
Fri Jan 19 06:19:09 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5a7f9a5a9c85c9b7851bbf267f5a12b9211f810e
      https://github.com/llvm/llvm-project/commit/5a7f9a5a9c85c9b7851bbf267f5a12b9211f810e
  Author: Yi Wu <43659785+yi-wu-arm at users.noreply.github.com>
  Date:   2024-01-19 (Fri, 19 Jan 2024)

  Changed paths:
    M flang/runtime/execute.cpp
    M flang/unittests/Runtime/CommandTest.cpp

  Log Message:
  -----------
  [flang] use setsid to assign the child to prevent zombie as it will be clean up by init process (#77944)

When using `setsid()` in a child process created by `fork()`, a new
session is created, and the child becomes a session leader. If the
parent process terminates before the child, the child becomes an orphan
and is adopted by the `init` process. The `init` process will eventually
clean up the child process once it exits.

However, killing the parent does not automatically kill the child; the
child will continue running until it exits.
Proper cleanup involves waiting for the child process to exit using
`wait()` or `waitpid()` in the parent process to avoid zombie processes,
but this approach is not valid for `EXECUTE_COMMAND_LINE` with async
mode.
Fix: https://github.com/llvm/llvm-project/issues/77803




More information about the All-commits mailing list