libc
libc copied to clipboard
Missing kill function in libc on Windows
The kill function is missing in libc on Windows
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::killif you spawn astd::Command- or
#[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.
Thank you for the enthusiasm here. However, as pointed out, this crate only provides bindings to system libraries (and some very minimal functions that reimplement C macros). It is even a bit lower level than windows, which makes use of Rust features to provide a much more user-friendly API.
A crate that provides a POSIX API for Windows is a very interesting idea; this just isn't the place for it (something like a fork of nix that supports Windows would be cool).