Skip to content

Commit 7ca0534

Browse files
committed
signal prototypes
1 parent 4fd9ed0 commit 7ca0534

File tree

10 files changed

+116
-77
lines changed

10 files changed

+116
-77
lines changed

contrib/win32/openssh/openbsd_compat.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\setproctitle.c" />
7676
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sha1.c" />
7777
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.c" />
78-
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.c" />
7978
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strlcat.c" />
8079
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strlcpy.c" />
8180
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strmode.c" />
@@ -121,7 +120,6 @@
121120
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\rmd160.h" />
122121
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sha1.h" />
123122
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.h" />
124-
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.h" />
125123
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sys-queue.h" />
126124
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sys-tree.h" />
127125
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\vis.h" />

contrib/win32/openssh/openbsd_compat.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@
180180
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.c">
181181
<Filter>Source Files</Filter>
182182
</ClCompile>
183-
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.c">
184-
<Filter>Source Files</Filter>
185-
</ClCompile>
186183
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strlcat.c">
187184
<Filter>Source Files</Filter>
188185
</ClCompile>
@@ -314,9 +311,6 @@
314311
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sha2.h">
315312
<Filter>Header Files</Filter>
316313
</ClInclude>
317-
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sigact.h">
318-
<Filter>Header Files</Filter>
319-
</ClInclude>
320314
<ClInclude Include="$(OpenSSH-Src-Path)openbsd-compat\sys-queue.h">
321315
<Filter>Header Files</Filter>
322316
</ClInclude>

contrib/win32/win32compat/inc/defs.h

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,34 @@
3030
#define FD_CLOEXEC 0x1
3131

3232
/* signal related defs*/
33-
typedef void(*sighandler_t)(int);
34-
// Signal types
35-
#define SIGINT 2 // interrupt
36-
#define SIGSEGV 11 // segment violation
33+
/* signal types */
34+
#define W32_SIGINT 0
35+
#define W32_SIGSEGV 1
3736

38-
#define SIGPIPE 27
39-
#define SIGCHLD 26
40-
#define SIGALRM 14
41-
#define SIGTSTP 5 //"CTRL+Z" - no portable number
37+
#define W32_SIGPIPE 2
38+
#define W32_SIGCHLD 3
39+
#define W32_SIGALRM 4
40+
#define W32_SIGTSTP 5
4241

43-
#define SIGHUP 1 //Terminate from console
44-
#define SIGQUIT 3
45-
#define SIGTERM 15// Software termination signal from kill
46-
#define SIGTTIN 6//noportabel number
47-
#define SIGTTOU 7 //no portable number
42+
#define W32_SIGHUP 6
43+
#define W32_SIGQUIT 7
44+
#define W32_SIGTERM 8
45+
#define W32_SIGTTIN 9
46+
#define W32_SIGTTOU 10
4847

48+
#define W32_SIGMAX 11
4949

50+
/* signal action codes*/
51+
#define W32_SIG_DFL 0
52+
#define W32_SIG_IGN 1
5053

51-
//#define SIGINT 2 // interrupt
52-
//#define SIGILL 4 // illegal instruction - invalid function image
53-
//#define SIGFPE 8 // floating point exception
54-
//#define SIGSEGV 11 // segment violation
55-
//#define SIGTERM 15 // Software termination signal from kill
56-
//#define SIGBREAK 21 // Ctrl-Break sequence
57-
//#define SIGABRT 22 // abnormal termination triggered by abort call
58-
//#define SIGWINCH
59-
//
60-
//#define SIGABRT_COMPAT 6 // SIGABRT compatible with other platforms, same as SIGABRT
61-
//
62-
//#define SIGALRM 14
63-
//#define SIGCHLD 26
64-
//#define SIGHUP 1
65-
//#define SIGPIPE 27
66-
//#define SIGQUIT 3
54+
/* singprocmask "how" codes*/
55+
#define SIG_BLOCK 0
56+
#define SIG_UNBLOCK 1
57+
#define SIG_SETMASK 2
6758

68-
// Signal action codes
69-
#define SIG_DFL (0) // default signal action
70-
#define SIG_IGN (1) // ignore signal
71-
#define SIG_GET (2) // return current value
72-
#define SIG_SGE (3) // signal gets error
73-
#define SIG_ACK (4) // acknowledge
59+
typedef void(*sighandler_t)(int);
60+
typedef int sigset_t;
61+
#define sigemptyset(set) (memset( (set), 0, sizeof(sigset_t)))
62+
#define sigaddset(set, sig) ( (*(set)) |= (0x80000000 >> (sig)))
63+
#define sigismember(set, sig) ( (*(set) & (0x80000000 >> (sig)))?1:0 )

contrib/win32/win32compat/inc/signal.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@
1010

1111
#define signal(a,b) w32_signal((a), (b))
1212
#define mysignal(a,b) w32_signal((a), (b))
13+
#define raise(a) w32_raise(a)
14+
#define kill(a,b) w32_kill((a), (b))
15+
#define sigprocmask(a,b,c) w32_sigprocmask((a), (b), (c))
1316

17+
#define SIGINT W32_SIGINT
18+
#define SIGSEGV W32_SIGSEGV
19+
#define SIGPIPE W32_SIGPIPE
20+
#define SIGCHLD W32_SIGCHLD
21+
#define SIGALRM W32_SIGALRM
22+
#define SIGSTP W32_SIGTSTP
23+
#define SIGHUP W32_SIGHUP
24+
#define SIGQUIT W32_SIGQUIT
25+
#define SIGTERM W32_SIGTERM
26+
#define SIGTTIN W32_SIGTTIN
27+
#define SIGTTOU W32_SIGTTOU
28+
29+
#define SIG_DFL W32_SIG_DFL
30+
#define SIG_IGN W32_SIG_IGN
1431

1532
#endif

contrib/win32/win32compat/inc/w32posix.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ int w32_dup2(int oldfd, int newfd);
6868
/* misc */
6969
unsigned int w32_alarm(unsigned int seconds);
7070
sighandler_t w32_signal(int signum, sighandler_t handler);
71+
int w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
72+
int w32_raise(int sig);
73+
int w32_kill(int pid, int sig);
74+
7175

7276
/* Shutdown constants */
7377
#define SHUT_WR SD_SEND
@@ -106,7 +110,7 @@ int w32_temp_DelChildToWatch(HANDLE processtowatch);
106110
int w32_temp_AddChildToWatch(HANDLE processtowatch);
107111
HANDLE w32_fd_to_handle(int fd);
108112
int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock);
109-
int signalio_add_child(HANDLE child);
113+
int sw_add_child(HANDLE child);
110114

111115
/* temporary definitions to aid in transition */
112116
#define WSHELPDelChildToWatch(a) w32_temp_DelChildToWatch((a))

contrib/win32/win32compat/signal.c

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,12 @@ struct _children {
4444
} children;
4545

4646
void
47-
signalio_initialize() {
47+
sw_initialize() {
4848
memset(&children, 0, sizeof(children));
4949
}
5050

51-
sighandler_t w32_signal(int signum, sighandler_t handler) {
52-
/*TODO - implement signal()*/
53-
return 0;
54-
}
55-
5651
int
57-
signalio_add_child(HANDLE child) {
52+
sw_add_child(HANDLE child) {
5853
if (children.num_children == MAX_CHILDREN) {
5954
errno = ENOTSUP;
6055
return -1;
@@ -64,7 +59,7 @@ signalio_add_child(HANDLE child) {
6459
}
6560

6661
int
67-
signalio_remove_child_at_index(DWORD index) {
62+
sw_remove_child_at_index(DWORD index) {
6863
if (index >= children.num_children) {
6964
errno = EINVAL;
7065
return -1;
@@ -81,13 +76,13 @@ signalio_remove_child_at_index(DWORD index) {
8176

8277

8378
int
84-
signalio_remove_child(HANDLE child) {
79+
sw_remove_child(HANDLE child) {
8580
HANDLE* handles = children.handles;
8681
DWORD num_children = children.num_children;
8782

8883
while (num_children) {
8984
if (*handles == child)
90-
return signalio_remove_child_at_index(children.num_children - num_children);
85+
return sw_remove_child_at_index(children.num_children - num_children);
9186
handles++;
9287
num_children--;
9388
}
@@ -97,6 +92,32 @@ signalio_remove_child(HANDLE child) {
9792
}
9893

9994

95+
unsigned int
96+
sw_alarm(unsigned int seconds) {
97+
return 0;
98+
}
99+
100+
101+
sighandler_t
102+
sw_signal(int signum, sighandler_t handler) {
103+
return NULL;
104+
}
105+
106+
int
107+
sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
108+
return 0;
109+
}
110+
111+
int
112+
sw_raise(int sig) {
113+
return 0;
114+
}
115+
116+
int
117+
sw_kill(int pid, int sig) {
118+
return 0;
119+
}
120+
100121
/*
101122
* Main wait routine used by all blocking calls.
102123
* It wakes up on
@@ -131,7 +152,7 @@ wait_for_any_event(HANDLE* events, int num_events, DWORD milli_seconds)
131152
/* is this due to a child process going down*/
132153
if (children.num_children && ((ret - WAIT_OBJECT_0) < children.num_children)) {
133154
/* TODO - enable this once all direct closes are removed in core code*/
134-
//signalio_remove_child(ret - WAIT_OBJECT_0);
155+
//sw_remove_child(ret - WAIT_OBJECT_0);
135156
errno = EINTR;
136157
return -1;
137158
}

contrib/win32/win32compat/w32fd.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ w32posix_initialize() {
124124
|| (socketio_initialize() != 0))
125125
DebugBreak();
126126
main_thread = OpenThread(THREAD_SET_CONTEXT, FALSE, GetCurrentThreadId());
127-
signalio_initialize();
127+
sw_initialize();
128128
}
129129

130130
void
@@ -739,21 +739,6 @@ w32_dup2(int oldfd, int newfd) {
739739
return -1;
740740
}
741741

742-
unsigned int
743-
w32_alarm(unsigned int seconds) {
744-
/*TODO - implement alarm */
745-
return 0;
746-
}
747-
748-
int
749-
w32_temp_DelChildToWatch(HANDLE processtowatch) {
750-
return 0;
751-
}
752-
753-
int w32_temp_AddChildToWatch(HANDLE processtowatch) {
754-
return 0;
755-
}
756-
757742
HANDLE
758743
w32_fd_to_handle(int fd) {
759744
HANDLE h = fd_table.w32_ios[fd]->handle;
@@ -782,3 +767,28 @@ int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock) {
782767
fd_table_set(pio, min_index);
783768
return min_index;
784769
}
770+
771+
772+
unsigned int
773+
w32_alarm(unsigned int seconds) {
774+
return 0;
775+
}
776+
sighandler_t
777+
w32_signal(int signum, sighandler_t handler) {
778+
return sw_signal(signum, handler);
779+
}
780+
781+
int
782+
w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
783+
return sw_sigprocmask(how, set, oldset);
784+
}
785+
786+
int
787+
w32_raise(int sig) {
788+
return sw_raise(sig);
789+
}
790+
791+
int
792+
w32_kill(int pid, int sig) {
793+
return sw_kill(pid, sig);
794+
}

contrib/win32/win32compat/w32fd.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <Windows.h>
1010
#include <stdio.h>
11-
#include "debug.h"
11+
#include "inc\defs.h"
1212

1313
enum w32_io_type {
1414
UNKNOWN_FD = 0,
@@ -122,9 +122,14 @@ FILE* fileio_fdopen(struct w32_io* pio, const char *mode);
122122
int termio_close(struct w32_io* pio);
123123

124124
/* signal related APIs*/
125-
void signalio_initialize();
126-
//int signalio_add_child(HANDLE child);
127-
//int signalio_remove_child(HANDLE child);
125+
void sw_initialize();
126+
int sw_add_child(HANDLE child);
127+
int sw_remove_child(HANDLE child);
128+
unsigned int sw_alarm(unsigned int seconds);
129+
sighandler_t sw_signal(int signum, sighandler_t handler);
130+
int sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
131+
int sw_raise(int sig);
132+
int sw_kill(int pid, int sig);
128133

129134
/*
130135
* open() flags and modes

serverloop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ collect_children(void)
882882

883883
session_close_by_pid(s->pid, status);
884884

885-
signalio_remove_child(process);
885+
sw_remove_child(process);
886886

887887
}
888888
}

session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ do_exec_no_pty(Session *s, const char *command)
920920

921921
s -> pid = pi.hProcess;
922922
s -> processId = pi.dwProcessId;
923-
signalio_add_child(pi.hProcess);
923+
sw_add_child(pi.hProcess);
924924

925925
// Add the child process created to select mux so that during our select data call we know if the process has exited
926926
/* TODO - fix thi s*/

0 commit comments

Comments
 (0)