Open chuacw opened 3 days ago
I did not find it in MSDN.
The implementation is missing in libc's implementation on Windows.
libc crate is a thin wrapper around platform's C libc, like glibc, msvcrt, musl, BSD libc. There is no corresponding kill functions on Windows MSVC libc. What #3764 does is adding a wrong abstraction. Take a look at the kill function signature:
int kill(pid_t pid, int sig);
What does pid_t
mean on Windows? Windows only uses HANDLE.
If you want to kill a process on Windows, you should use either:
std::process::Child::kill
if you spawn a std::Command
#[cfg(windows)]
your code and use specific lower level windows APIs that crates like winapi or windows-sys exposed.The initial PR used a different signature than expected because of styling issues that causes a ci failure when I used the same signature. It has now been fixed.
The added kill function is to provide parity with the existing kill function and usage on other platforms.
Thanks.
Scope of libc states that this crate wraps "VS CRT libraries" and is "distinct from the winapi crate as well as bindings to common system DLLs found on Windows".
Therefore we should not be depending on winapi nor duplicating their bindings.
See also point 3 Unresolved questions
Even if it is a yes, then only bare Win32 APIs will be exposed, not compositions/emulations of them.
The kill function is missing in libc on Windows