[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:05:58 PST 2023


yi-wu-arm wrote:

> Given that you have implementations using `fork()` and its Windows analog, why have synchronous implementations with `system()`? Can't the synchronous path just use the asynchronous implementation with synchronization?

Yes it is do-able. I think that would reduce readability, my current structure is
```cpp
if(sync){
    system(cmd);
}else{
  if (Windows){
      CreateProcess(cmd);
  }else {
      fork();
      system(cmd)
}
```
If wait in async, making it sync:
```cpp
if (Windows){
    CreateProcess(cmd);
    if(sync){
        wait()
    }else{
        no_wait()
    }
}else{
    fork()
    system(cmd)
    if(sync){
        wait_pid()
    }else{
        no_wait()
    }
}
```

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


More information about the flang-commits mailing list