[flang-commits] [flang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

Yi Wu via flang-commits flang-commits at lists.llvm.org
Fri Dec 1 09:52:12 PST 2023


yi-wu-arm wrote:

> That makes sense, given that you want to use `system()` rather than `fork()` and `execvp()`. On the asynchronous POSIX path you're actually creating two processes rather than one, unfortunately.
> 
> Do you ever use `waitpid()` to harvest these completed processes? If not, they'll occupy system resources until the program exits.

I think `system` is internal implemented with `fork(0` and `execl` synchronously, so yes it will create two process not one. On Linux async, there is an `exit(status)` to quit the async process. 
On Windows there is none. Although I have this, when `CreateProcess` return a success status. But I don't think it will actually do anything since I didn't wait the process to finish.  (But if I wait, that will make it sync instead of async...)
```cpp
      CloseHandle(pi.hProcess);
      CloseHandle(pi.hThread);
```


https://github.com/llvm/llvm-project/pull/74077


More information about the flang-commits mailing list