mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-20 04:24:44 +02:00
signal prototypes
This commit is contained in:
parent
4fd9ed0bd7
commit
7ca05346bb
@ -75,7 +75,6 @@
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\setproctitle.c" />
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sha1.c" />
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.c" />
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.c" />
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strlcat.c" />
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strlcpy.c" />
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strmode.c" />
|
||||
@ -121,7 +120,6 @@
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\rmd160.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sha1.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sys-queue.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sys-tree.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\vis.h" />
|
||||
|
@ -180,9 +180,6 @@
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strlcat.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -314,9 +311,6 @@
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sys-queue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -30,44 +30,34 @@
|
||||
#define FD_CLOEXEC 0x1
|
||||
|
||||
/* signal related defs*/
|
||||
/* signal types */
|
||||
#define W32_SIGINT 0
|
||||
#define W32_SIGSEGV 1
|
||||
|
||||
#define W32_SIGPIPE 2
|
||||
#define W32_SIGCHLD 3
|
||||
#define W32_SIGALRM 4
|
||||
#define W32_SIGTSTP 5
|
||||
|
||||
#define W32_SIGHUP 6
|
||||
#define W32_SIGQUIT 7
|
||||
#define W32_SIGTERM 8
|
||||
#define W32_SIGTTIN 9
|
||||
#define W32_SIGTTOU 10
|
||||
|
||||
#define W32_SIGMAX 11
|
||||
|
||||
/* signal action codes*/
|
||||
#define W32_SIG_DFL 0
|
||||
#define W32_SIG_IGN 1
|
||||
|
||||
/* singprocmask "how" codes*/
|
||||
#define SIG_BLOCK 0
|
||||
#define SIG_UNBLOCK 1
|
||||
#define SIG_SETMASK 2
|
||||
|
||||
typedef void(*sighandler_t)(int);
|
||||
// Signal types
|
||||
#define SIGINT 2 // interrupt
|
||||
#define SIGSEGV 11 // segment violation
|
||||
|
||||
#define SIGPIPE 27
|
||||
#define SIGCHLD 26
|
||||
#define SIGALRM 14
|
||||
#define SIGTSTP 5 //"CTRL+Z" - no portable number
|
||||
|
||||
#define SIGHUP 1 //Terminate from console
|
||||
#define SIGQUIT 3
|
||||
#define SIGTERM 15// Software termination signal from kill
|
||||
#define SIGTTIN 6//noportabel number
|
||||
#define SIGTTOU 7 //no portable number
|
||||
|
||||
|
||||
|
||||
//#define SIGINT 2 // interrupt
|
||||
//#define SIGILL 4 // illegal instruction - invalid function image
|
||||
//#define SIGFPE 8 // floating point exception
|
||||
//#define SIGSEGV 11 // segment violation
|
||||
//#define SIGTERM 15 // Software termination signal from kill
|
||||
//#define SIGBREAK 21 // Ctrl-Break sequence
|
||||
//#define SIGABRT 22 // abnormal termination triggered by abort call
|
||||
//#define SIGWINCH
|
||||
//
|
||||
//#define SIGABRT_COMPAT 6 // SIGABRT compatible with other platforms, same as SIGABRT
|
||||
//
|
||||
//#define SIGALRM 14
|
||||
//#define SIGCHLD 26
|
||||
//#define SIGHUP 1
|
||||
//#define SIGPIPE 27
|
||||
//#define SIGQUIT 3
|
||||
|
||||
// Signal action codes
|
||||
#define SIG_DFL (0) // default signal action
|
||||
#define SIG_IGN (1) // ignore signal
|
||||
#define SIG_GET (2) // return current value
|
||||
#define SIG_SGE (3) // signal gets error
|
||||
#define SIG_ACK (4) // acknowledge
|
||||
typedef int sigset_t;
|
||||
#define sigemptyset(set) (memset( (set), 0, sizeof(sigset_t)))
|
||||
#define sigaddset(set, sig) ( (*(set)) |= (0x80000000 >> (sig)))
|
||||
#define sigismember(set, sig) ( (*(set) & (0x80000000 >> (sig)))?1:0 )
|
||||
|
@ -10,6 +10,23 @@
|
||||
|
||||
#define signal(a,b) w32_signal((a), (b))
|
||||
#define mysignal(a,b) w32_signal((a), (b))
|
||||
#define raise(a) w32_raise(a)
|
||||
#define kill(a,b) w32_kill((a), (b))
|
||||
#define sigprocmask(a,b,c) w32_sigprocmask((a), (b), (c))
|
||||
|
||||
#define SIGINT W32_SIGINT
|
||||
#define SIGSEGV W32_SIGSEGV
|
||||
#define SIGPIPE W32_SIGPIPE
|
||||
#define SIGCHLD W32_SIGCHLD
|
||||
#define SIGALRM W32_SIGALRM
|
||||
#define SIGSTP W32_SIGTSTP
|
||||
#define SIGHUP W32_SIGHUP
|
||||
#define SIGQUIT W32_SIGQUIT
|
||||
#define SIGTERM W32_SIGTERM
|
||||
#define SIGTTIN W32_SIGTTIN
|
||||
#define SIGTTOU W32_SIGTTOU
|
||||
|
||||
#define SIG_DFL W32_SIG_DFL
|
||||
#define SIG_IGN W32_SIG_IGN
|
||||
|
||||
#endif
|
@ -68,6 +68,10 @@ int w32_dup2(int oldfd, int newfd);
|
||||
/* misc */
|
||||
unsigned int w32_alarm(unsigned int seconds);
|
||||
sighandler_t w32_signal(int signum, sighandler_t handler);
|
||||
int w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
|
||||
int w32_raise(int sig);
|
||||
int w32_kill(int pid, int sig);
|
||||
|
||||
|
||||
/* Shutdown constants */
|
||||
#define SHUT_WR SD_SEND
|
||||
@ -106,7 +110,7 @@ int w32_temp_DelChildToWatch(HANDLE processtowatch);
|
||||
int w32_temp_AddChildToWatch(HANDLE processtowatch);
|
||||
HANDLE w32_fd_to_handle(int fd);
|
||||
int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock);
|
||||
int signalio_add_child(HANDLE child);
|
||||
int sw_add_child(HANDLE child);
|
||||
|
||||
/* temporary definitions to aid in transition */
|
||||
#define WSHELPDelChildToWatch(a) w32_temp_DelChildToWatch((a))
|
||||
|
@ -44,17 +44,12 @@ struct _children {
|
||||
} children;
|
||||
|
||||
void
|
||||
signalio_initialize() {
|
||||
sw_initialize() {
|
||||
memset(&children, 0, sizeof(children));
|
||||
}
|
||||
|
||||
sighandler_t w32_signal(int signum, sighandler_t handler) {
|
||||
/*TODO - implement signal()*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
signalio_add_child(HANDLE child) {
|
||||
sw_add_child(HANDLE child) {
|
||||
if (children.num_children == MAX_CHILDREN) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
@ -64,7 +59,7 @@ signalio_add_child(HANDLE child) {
|
||||
}
|
||||
|
||||
int
|
||||
signalio_remove_child_at_index(DWORD index) {
|
||||
sw_remove_child_at_index(DWORD index) {
|
||||
if (index >= children.num_children) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@ -81,13 +76,13 @@ signalio_remove_child_at_index(DWORD index) {
|
||||
|
||||
|
||||
int
|
||||
signalio_remove_child(HANDLE child) {
|
||||
sw_remove_child(HANDLE child) {
|
||||
HANDLE* handles = children.handles;
|
||||
DWORD num_children = children.num_children;
|
||||
|
||||
while (num_children) {
|
||||
if (*handles == child)
|
||||
return signalio_remove_child_at_index(children.num_children - num_children);
|
||||
return sw_remove_child_at_index(children.num_children - num_children);
|
||||
handles++;
|
||||
num_children--;
|
||||
}
|
||||
@ -97,6 +92,32 @@ signalio_remove_child(HANDLE child) {
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
sw_alarm(unsigned int seconds) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sighandler_t
|
||||
sw_signal(int signum, sighandler_t handler) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sw_raise(int sig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sw_kill(int pid, int sig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Main wait routine used by all blocking calls.
|
||||
* It wakes up on
|
||||
@ -131,7 +152,7 @@ wait_for_any_event(HANDLE* events, int num_events, DWORD milli_seconds)
|
||||
/* is this due to a child process going down*/
|
||||
if (children.num_children && ((ret - WAIT_OBJECT_0) < children.num_children)) {
|
||||
/* TODO - enable this once all direct closes are removed in core code*/
|
||||
//signalio_remove_child(ret - WAIT_OBJECT_0);
|
||||
//sw_remove_child(ret - WAIT_OBJECT_0);
|
||||
errno = EINTR;
|
||||
return -1;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ w32posix_initialize() {
|
||||
|| (socketio_initialize() != 0))
|
||||
DebugBreak();
|
||||
main_thread = OpenThread(THREAD_SET_CONTEXT, FALSE, GetCurrentThreadId());
|
||||
signalio_initialize();
|
||||
sw_initialize();
|
||||
}
|
||||
|
||||
void
|
||||
@ -739,21 +739,6 @@ w32_dup2(int oldfd, int newfd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
w32_alarm(unsigned int seconds) {
|
||||
/*TODO - implement alarm */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
w32_temp_DelChildToWatch(HANDLE processtowatch) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w32_temp_AddChildToWatch(HANDLE processtowatch) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HANDLE
|
||||
w32_fd_to_handle(int fd) {
|
||||
HANDLE h = fd_table.w32_ios[fd]->handle;
|
||||
@ -782,3 +767,28 @@ int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock) {
|
||||
fd_table_set(pio, min_index);
|
||||
return min_index;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
w32_alarm(unsigned int seconds) {
|
||||
return 0;
|
||||
}
|
||||
sighandler_t
|
||||
w32_signal(int signum, sighandler_t handler) {
|
||||
return sw_signal(signum, handler);
|
||||
}
|
||||
|
||||
int
|
||||
w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
|
||||
return sw_sigprocmask(how, set, oldset);
|
||||
}
|
||||
|
||||
int
|
||||
w32_raise(int sig) {
|
||||
return sw_raise(sig);
|
||||
}
|
||||
|
||||
int
|
||||
w32_kill(int pid, int sig) {
|
||||
return sw_kill(pid, sig);
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include "debug.h"
|
||||
#include "inc\defs.h"
|
||||
|
||||
enum w32_io_type {
|
||||
UNKNOWN_FD = 0,
|
||||
@ -122,9 +122,14 @@ FILE* fileio_fdopen(struct w32_io* pio, const char *mode);
|
||||
int termio_close(struct w32_io* pio);
|
||||
|
||||
/* signal related APIs*/
|
||||
void signalio_initialize();
|
||||
//int signalio_add_child(HANDLE child);
|
||||
//int signalio_remove_child(HANDLE child);
|
||||
void sw_initialize();
|
||||
int sw_add_child(HANDLE child);
|
||||
int sw_remove_child(HANDLE child);
|
||||
unsigned int sw_alarm(unsigned int seconds);
|
||||
sighandler_t sw_signal(int signum, sighandler_t handler);
|
||||
int sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
|
||||
int sw_raise(int sig);
|
||||
int sw_kill(int pid, int sig);
|
||||
|
||||
/*
|
||||
* open() flags and modes
|
||||
|
@ -882,7 +882,7 @@ collect_children(void)
|
||||
|
||||
session_close_by_pid(s->pid, status);
|
||||
|
||||
signalio_remove_child(process);
|
||||
sw_remove_child(process);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
|
||||
s -> pid = pi.hProcess;
|
||||
s -> processId = pi.dwProcessId;
|
||||
signalio_add_child(pi.hProcess);
|
||||
sw_add_child(pi.hProcess);
|
||||
|
||||
// Add the child process created to select mux so that during our select data call we know if the process has exited
|
||||
/* TODO - fix thi s*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user