Implement sigaction for Windows.
authorBruce Cran <bruce@cran.org.uk>
Wed, 22 Feb 2012 19:56:22 +0000 (19:56 +0000)
committerJens Axboe <axboe@kernel.dk>
Wed, 22 Feb 2012 20:11:35 +0000 (21:11 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
os/windows/posix.c

index ea3736d..ba7abb5 100755 (executable)
@@ -124,8 +124,17 @@ void syslog(int priority, const char *message, ... /* argument */)
 int sigaction(int sig, const struct sigaction *act,
                struct sigaction *oact)
 {
-       errno = ENOSYS;
-       return (-1);
+       int rc = 0;
+       void (*prev_handler)(int);
+
+       prev_handler = signal(sig, act->sa_handler);
+       if (oact != NULL)
+               oact->sa_handler = prev_handler;
+
+       if (prev_handler == SIG_ERR)
+               rc = -1;
+
+       return rc;
 }
 
 int lstat(const char * path, struct stat * buf)