diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2022-06-24 13:08:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2022-06-24 13:08:23 +0300 |
commit | 067fd14417000b3601483f660fe9e27c3b47f0b5 (patch) | |
tree | eb4fc96bcae1331d15432f6555b003185bc75848 /contrib/libs/postgresql/src/port/kill.c | |
parent | ece86e83e77dcf3d9e757517d3d16f707272a4c7 (diff) | |
download | ydb-067fd14417000b3601483f660fe9e27c3b47f0b5.tar.gz |
REVERT: r9621717 (disable pg_wrapper for OSS) YQ-1154
ref:d888564254e64ea675383c26661ff5332bf406f5
Diffstat (limited to 'contrib/libs/postgresql/src/port/kill.c')
-rw-r--r-- | contrib/libs/postgresql/src/port/kill.c | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/contrib/libs/postgresql/src/port/kill.c b/contrib/libs/postgresql/src/port/kill.c deleted file mode 100644 index 99b35de45b..0000000000 --- a/contrib/libs/postgresql/src/port/kill.c +++ /dev/null @@ -1,97 +0,0 @@ -/*------------------------------------------------------------------------- - * - * kill.c - * kill() - * - * Copyright (c) 1996-2021, PostgreSQL Global Development Group - * - * This is a replacement version of kill for Win32 which sends - * signals that the backend can recognize. - * - * IDENTIFICATION - * src/port/kill.c - * - *------------------------------------------------------------------------- - */ - -#include "c.h" - -#ifdef WIN32 -/* signal sending */ -int -pgkill(int pid, int sig) -{ - char pipename[128]; - BYTE sigData = sig; - BYTE sigRet = 0; - DWORD bytes; - - /* we allow signal 0 here, but it will be ignored in pg_queue_signal */ - if (sig >= PG_SIGNAL_COUNT || sig < 0) - { - errno = EINVAL; - return -1; - } - if (pid <= 0) - { - /* No support for process groups */ - errno = EINVAL; - return -1; - } - - /* special case for SIGKILL: just ask the system to terminate the target */ - if (sig == SIGKILL) - { - HANDLE prochandle; - - if ((prochandle = OpenProcess(PROCESS_TERMINATE, FALSE, (DWORD) pid)) == NULL) - { - errno = ESRCH; - return -1; - } - if (!TerminateProcess(prochandle, 255)) - { - _dosmaperr(GetLastError()); - CloseHandle(prochandle); - return -1; - } - CloseHandle(prochandle); - return 0; - } - snprintf(pipename, sizeof(pipename), "\\\\.\\pipe\\pgsignal_%u", pid); - - if (CallNamedPipe(pipename, &sigData, 1, &sigRet, 1, &bytes, 1000)) - { - if (bytes != 1 || sigRet != sig) - { - errno = ESRCH; - return -1; - } - return 0; - } - - switch (GetLastError()) - { - case ERROR_BROKEN_PIPE: - case ERROR_BAD_PIPE: - - /* - * These arise transiently as a process is exiting. Treat them - * like POSIX treats a zombie process, reporting success. - */ - return 0; - - case ERROR_FILE_NOT_FOUND: - /* pipe fully gone, so treat the process as gone */ - errno = ESRCH; - return -1; - case ERROR_ACCESS_DENIED: - errno = EPERM; - return -1; - default: - errno = EINVAL; /* unexpected */ - return -1; - } -} - -#endif |