mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 19:28:29 +00:00
Fix some win32 definitions
You can now use psapi.dll and pdh.dll. Some TODOs for Windows have been cleared out. We might have a working load average for the platform that should help GNU Make work well.
This commit is contained in:
parent
e2e0b042c1
commit
c23b6ecc31
162 changed files with 847 additions and 153 deletions
|
@ -23,24 +23,34 @@
|
|||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/enum/ctrlevent.h"
|
||||
#include "libc/nt/enum/processaccess.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int sys_kill_nt(int pid, int sig) {
|
||||
bool ok;
|
||||
int event;
|
||||
int64_t handle;
|
||||
int event, ntpid;
|
||||
if (pid) {
|
||||
pid = ABS(pid);
|
||||
if ((event = GetConsoleCtrlEvent(sig)) != -1) {
|
||||
ok = !!GenerateConsoleCtrlEvent(
|
||||
event, __isfdkind(pid, kFdProcess) ? GetProcessId(g_fds.p[pid].handle)
|
||||
: pid);
|
||||
/* kill(pid, SIGINT|SIGHUP|SIGQUIT) */
|
||||
if (__isfdkind(pid, kFdProcess)) {
|
||||
ntpid = GetProcessId(g_fds.p[pid].handle);
|
||||
} else if (!__isfdopen(pid)) {
|
||||
/* XXX: this is sloppy (see fork-nt.c) */
|
||||
ntpid = pid;
|
||||
} else {
|
||||
return esrch();
|
||||
}
|
||||
ok = !!GenerateConsoleCtrlEvent(event, ntpid);
|
||||
} else if (__isfdkind(pid, kFdProcess)) {
|
||||
ok = !!TerminateProcess(g_fds.p[pid].handle, 128 + sig);
|
||||
} else if ((handle = OpenProcess(kNtProcessAllAccess, false, pid))) {
|
||||
if (!ok && GetLastError() == kNtErrorAccessDenied) ok = true;
|
||||
} else if ((handle = OpenProcess(kNtProcessTerminate, false, pid))) {
|
||||
ok = !!TerminateProcess(handle, 128 + sig);
|
||||
if (!ok && GetLastError() == kNtErrorAccessDenied) ok = true;
|
||||
CloseHandle(handle);
|
||||
} else {
|
||||
ok = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue