WindowsXP-SP1/base/subsys/posix/psxss/consignl.c
2020-09-30 16:53:49 +02:00

87 lines
1.4 KiB
C

/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
consignl.c
Abstract:
This module contains the handler for signals received from PSXSES.
Author:
Avi Nathan (avin) 17-Jul-1991
Revision History:
Ellen Aycock-Wright (ellena) 15-Sept-1991 Modified for POSIX
--*/
#include "psxsrv.h"
#define NTPSX_ONLY
#include "sesport.h"
#include <windows.h>
#include <wincon.h>
NTSTATUS
PsxCtrlSignalHandler(
IN OUT PVOID RequestMsg
)
{
PPSX_PROCESS Process;
PPSX_SESSION Session;
PPSXSESREQUESTMSG Msg;
PPSX_PROCESS p;
int Signal;
Msg = RequestMsg;
switch (Msg->d.Signal.Type) {
case PSX_SIGINT:
Signal = SIGINT;
break;
case PSX_SIGQUIT:
Signal = SIGQUIT;
break;
case PSX_SIGTSTP:
Signal = SIGTSTP;
break;
case PSX_SIGKILL:
Signal = SIGKILL;
break;
default:
KdPrint(("PSXSS: Unknown signal type.\n"));
Signal = 0;
break;
}
Session = PsxLocateSessionByUniqueId(Msg->UniqueId);
if (NULL == Session) {
KdPrint(("PSXSS: ConSignl: could not locate session\n"));
return STATUS_SUCCESS;
}
//
// Send the signal to every process associated with the session.
//
AcquireProcessStructureLock();
for (p = FirstProcess; p < LastProcess; p++) {
if (p->Flags & P_FREE)
continue;
if (p->PsxSession == Session) {
PsxSignalProcess(p, Signal);
}
}
ReleaseProcessStructureLock();
return STATUS_SUCCESS;
}