Skip to content
Snippets Groups Projects
Commit c33e76ab authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

includes kill() for NT

Rev: src/signal_handler.c:1.33
parent 8a222b55
Branches
No related tags found
No related merge requests found
......@@ -94,6 +94,14 @@ struct sigdesc
* All known signals
*/
#ifdef __NT__
#ifndef SIGKILL
#define SIGKILL 9
#endif
#endif /* __NT__ */
static struct sigdesc signal_desc []={
#ifdef SIGHUP
{ SIGHUP, "SIGHUP" },
......@@ -1215,6 +1223,67 @@ static void f_kill(INT32 args)
pop_n_elems(args-1);
}
#else
#ifdef __NT__
void f_kill(INT32 args)
{
HANDLE proc=INVALID_HANDLE_VALUE;
if(args < 2)
error("Too few arguments to kill().\n");
switch(sp[-args].type)
{
case T_INT:
proc=OpenProcess(PROCESS_TERMINATE,
0,
sp[-args].u.integer);
if(proc==INVALID_HANDLE_VALUE)
{
errno=EPERM;
pop_n_elems(args);
push_int(-1);
return;
}
break;
case T_OBJECT:
{
INT32 pid;
struct pid_status *p;
if((p=(struct pid_status *)get_storage(sp[-args].u.object,
pid_status_program)))
{
proc=p->handle;
break;
}
}
default:
error("Bad argument 1 to kill().\n");
}
if(sp[1-args].type != T_INT)
error("Bad argument 1 to kill().\n");
switch(sp[1-args].u.integer)
{
case SIGKILL:
{
int i=TerminateProcess(proc,0xff)?0:-1;
pop_n_elems(args);
push_int(i);
check_signals(0,0,0);
break;
}
default:
error("Unknown signal %d\n",sp[1-args].u.integer);
}
}
#endif
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment