signal support initial changes

This commit is contained in:
manojampalam 2016-03-15 23:00:55 -07:00
parent 6ba1ba551a
commit 4fd9ed0bd7
5 changed files with 76 additions and 35 deletions

View File

@ -28,3 +28,46 @@
/*fd flags*/ /*fd flags*/
#define FD_CLOEXEC 0x1 #define FD_CLOEXEC 0x1
/* signal related defs*/
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

View File

@ -8,28 +8,8 @@
#include "w32posix.h" #include "w32posix.h"
// Signal types #define signal(a,b) w32_signal((a), (b))
#define SIGINT 2 // interrupt #define mysignal(a,b) w32_signal((a), (b))
#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 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
#endif #endif

View File

@ -67,10 +67,7 @@ int w32_dup2(int oldfd, int newfd);
/* misc */ /* misc */
unsigned int w32_alarm(unsigned int seconds); unsigned int w32_alarm(unsigned int seconds);
typedef void(*sighandler_t)(int); sighandler_t w32_signal(int signum, sighandler_t handler);
#define signal(a,b) w32_signal((a), (b))
#define mysignal(a,b) w32_signal((a), (b))
/* Shutdown constants */ /* Shutdown constants */
#define SHUT_WR SD_SEND #define SHUT_WR SD_SEND

View File

@ -30,6 +30,7 @@
#include "w32fd.h" #include "w32fd.h"
#include <errno.h> #include <errno.h>
#include "inc\defs.h"
/* signal handlers */ /* signal handlers */
@ -47,6 +48,11 @@ signalio_initialize() {
memset(&children, 0, sizeof(children)); memset(&children, 0, sizeof(children));
} }
sighandler_t w32_signal(int signum, sighandler_t handler) {
/*TODO - implement signal()*/
return 0;
}
int int
signalio_add_child(HANDLE child) { signalio_add_child(HANDLE child) {
if (children.num_children == MAX_CHILDREN) { if (children.num_children == MAX_CHILDREN) {

View File

@ -453,6 +453,28 @@ w32_close(int fd) {
} }
} }
static int
w32_io_process_fd_flags(struct w32_io* pio, int flags) {
DWORD shi_flags;
if (flags & ~FD_CLOEXEC) {
debug("fcntl - ERROR unsupported flags %d, io:%p", flags, pio);
errno = ENOTSUP;
return -1;
}
shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT;
if (SetHandleInformation(WINHANDLE(pio), HANDLE_FLAG_INHERIT, shi_flags) == FALSE) {
debug("fcntl - SetHandleInformation failed %d, io:%p",
GetLastError(), pio);
errno = EOTHER;
return -1;
}
pio->fd_flags = flags;
return 0;
}
int int
w32_fcntl(int fd, int cmd, ... /* arg */) { w32_fcntl(int fd, int cmd, ... /* arg */) {
va_list valist; va_list valist;
@ -468,10 +490,8 @@ w32_fcntl(int fd, int cmd, ... /* arg */) {
return 0; return 0;
case F_GETFD: case F_GETFD:
return fd_table.w32_ios[fd]->fd_flags; return fd_table.w32_ios[fd]->fd_flags;
return 0;
case F_SETFD: case F_SETFD:
fd_table.w32_ios[fd]->fd_flags = va_arg(valist, int); return w32_io_process_fd_flags(fd_table.w32_ios[fd], va_arg(valist, int));
return 0;
default: default:
errno = EINVAL; errno = EINVAL;
debug("fcntl - ERROR not supported cmd:%d", cmd); debug("fcntl - ERROR not supported cmd:%d", cmd);
@ -725,11 +745,6 @@ w32_alarm(unsigned int seconds) {
return 0; return 0;
} }
sighandler_t w32_signal(int signum, sighandler_t handler) {
/*TODO - implement signal()*/
return 0;
}
int int
w32_temp_DelChildToWatch(HANDLE processtowatch) { w32_temp_DelChildToWatch(HANDLE processtowatch) {
return 0; return 0;