You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently runDetached returns a ProcessIdentifier, which contains a pidfd on Linux and HANDLE on Windows. These handles are closed as soon as runDetached returns, making the values effectively useless to the caller. Similar to #92, there is a Windows-specific race condition here. On Unix the pid will be valid until someone waitid's it, so a caller _could_ use pidfd_open to get a new pidfd. But on Windows the ProcessIdentifier may already be invalid by the time runDetached returns and therefore OpenProcess can't be used to recover a handle. On FreeBSD one can't get a process descriptor from a PID at all (PDs are only for child processes).
In order to avoid these race conditions, runDetached would need to either return a type which manages the lifetime of the various platform-specific handles, or leak the handles and leave them to be managed by the user. Due to questionable utility of these APIs in the first place (the closure based API can be used in conjunction with a Task to do pretty much everything runDetached can, without the downsides), we simply remove them.
Closes#94
Copy file name to clipboardExpand all lines: README.md
-15Lines changed: 0 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,21 +78,6 @@ async let monitorResult = run(
78
78
}
79
79
```
80
80
81
-
### Running Unmonitored Processes
82
-
83
-
While `Subprocess` is designed with Swift’s structural concurrency in mind, it also provides a lower level, synchronous method for launching child processes. However, since `Subprocess` can’t synchronously monitor child process’s state or handle cleanup, you’ll need to attach a FileDescriptor to each I/O directly. Remember to close the `FileDescriptor` once you’re finished.
84
-
85
-
```swift
86
-
importSubprocess
87
-
88
-
let input: FileDescriptor =...
89
-
90
-
input.closeAfter {
91
-
let pid =tryrunDetached(.path("/bin/daemon"), input: input)
92
-
// ... other opeartions
93
-
}
94
-
```
95
-
96
81
### Customizable Execution
97
82
98
83
You can set various parameters when running the child process, such as `Arguments`, `Environment`, and working directory:
0 commit comments