rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.02k stars 1.01k forks source link

Missing kill function in libc on Windows #3763

Open chuacw opened 3 days ago

chuacw commented 3 days ago

The kill function is missing in libc on Windows

devnexen commented 1 day ago

I did not find it in MSDN.

chuacw commented 1 day ago

The implementation is missing in libc's implementation on Windows.

faptc commented 1 day ago

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:

chuacw commented 1 day ago

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.

ChrisDenton commented 1 day ago

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.

chuacw commented 1 day ago

See also point 3 Unresolved questions

faptc commented 1 day ago

Even if it is a yes, then only bare Win32 APIs will be exposed, not compositions/emulations of them.