summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src
diff options
context:
space:
mode:
authorsbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 19:32:26 +0000
committersbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 19:32:26 +0000
commit9c2b8ef4f40a37af64c2f72fb4b34df19178678e (patch)
tree93485da1c53a9d79b7891cbbd5320155aa9f1d33 /native_client_sdk/src
parentbde558620906b2cf6a8604f0c2199dfb8f25a7da (diff)
downloadchromium_src-9c2b8ef4f40a37af64c2f72fb4b34df19178678e.zip
chromium_src-9c2b8ef4f40a37af64c2f72fb4b34df19178678e.tar.gz
chromium_src-9c2b8ef4f40a37af64c2f72fb4b34df19178678e.tar.bz2
[NaCl SDK] nacl_io: Add plumbing for kill/signal/ioctl.
R=binji@chromium.org Review URL: https://codereview.chromium.org/23068034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src')
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_listener.cc6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/include/sys/ioctl.h16
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc28
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_intercept.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc11
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_proxy.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap.h6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/library.dsc8
-rw-r--r--native_client_sdk/src/libraries/nacl_io/ossignal.h17
-rw-r--r--native_client_sdk/src/libraries/nacl_io/syscalls/ioctl.c10
-rw-r--r--native_client_sdk/src/libraries/nacl_io/syscalls/kill.c10
-rw-r--r--native_client_sdk/src/libraries/nacl_io/syscalls/signal.c10
-rw-r--r--native_client_sdk/src/libraries/nacl_io/syscalls/sigset.c10
-rw-r--r--native_client_sdk/src/libraries/third_party/newlib-extras/sys/signal.h311
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h10
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc18
16 files changed, 467 insertions, 12 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/event_listener.cc b/native_client_sdk/src/libraries/nacl_io/event_listener.cc
index de1b557..11297b6 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_listener.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_listener.cc
@@ -175,9 +175,9 @@ Error EventListener::Wait(EventData* events,
}
Error EventListener::Track(int id,
- const ScopedEventEmitter& emitter,
- uint32_t filter,
- uint64_t user_data) {
+ const ScopedEventEmitter& emitter,
+ uint32_t filter,
+ uint64_t user_data) {
AUTO_LOCK(info_lock_);
EventInfoMap_t::iterator it = event_info_map_.find(id);
diff --git a/native_client_sdk/src/libraries/nacl_io/include/sys/ioctl.h b/native_client_sdk/src/libraries/nacl_io/include/sys/ioctl.h
new file mode 100644
index 0000000..c4e0d1c
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/include/sys/ioctl.h
@@ -0,0 +1,16 @@
+/* Copyright 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+#ifndef LIBRARIES_NACL_IO_INCLUDE_SYS_IOCTL_H_
+#define LIBRARIES_NACL_IO_INCLUDE_SYS_IOCTL_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+int ioctl(int fd, unsigned long request, ...);
+
+__END_DECLS
+
+#endif /* LIBRARIES_NACL_IO_INCLUDE_SYS_IOCTL_H_ */
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
index cb51734..b378e86 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
@@ -22,6 +22,7 @@ using namespace nacl_io;
}
static KernelProxy* s_kp;
+static bool s_kp_owned;
void ki_init(void* kp) {
ki_init_ppapi(kp, 0, NULL);
@@ -32,8 +33,14 @@ void ki_init_ppapi(void* kp,
PPB_GetInterface get_browser_interface) {
kernel_wrap_init();
- if (kp == NULL) kp = new KernelProxy();
- s_kp = static_cast<KernelProxy*>(kp);
+ if (kp == NULL) {
+ s_kp = new KernelProxy();
+ s_kp_owned = true;
+ } else {
+ s_kp = static_cast<KernelProxy*>(kp);
+ s_kp_owned = false;
+ }
+
PepperInterface* ppapi = NULL;
if (instance && get_browser_interface)
@@ -48,6 +55,8 @@ int ki_is_initialized() {
void ki_uninit() {
kernel_wrap_uninit();
+ if (s_kp_owned)
+ delete s_kp;
s_kp = NULL;
}
@@ -257,6 +266,21 @@ int ki_tcsetattr(int fd, int optional_actions,
return s_kp->tcsetattr(fd, optional_actions, termios_p);
}
+int ki_kill(pid_t pid, int sig) {
+ ON_NOSYS_RETURN(-1);
+ return s_kp->kill(pid, sig);
+}
+
+sighandler_t ki_signal(int signum, sighandler_t handler) {
+ ON_NOSYS_RETURN(SIG_ERR);
+ return s_kp->sigset(signum, handler);
+}
+
+sighandler_t ki_sigset(int signum, sighandler_t handler) {
+ ON_NOSYS_RETURN(SIG_ERR);
+ return s_kp->sigset(signum, handler);
+}
+
#ifdef PROVIDES_SOCKET_API
// Socket Functions
int ki_accept(int fd, struct sockaddr* addr, socklen_t* len) {
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h
index 6ef44b3..c17b61c 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h
@@ -8,6 +8,7 @@
#include <ppapi/c/ppb.h>
#include <ppapi/c/pp_instance.h>
+#include "nacl_io/ossignal.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/osstat.h"
#include "nacl_io/ostermios.h"
@@ -75,6 +76,9 @@ int ki_tcflush(int fd, int queue_selector);
int ki_tcgetattr(int fd, struct termios* termios_p);
int ki_tcsetattr(int fd, int optional_actions,
const struct termios *termios_p);
+int ki_kill(pid_t pid, int sig);
+sighandler_t ki_signal(int signum, sighandler_t handler);
+sighandler_t ki_sigset(int signum, sighandler_t handler);
#ifdef PROVIDES_SOCKET_API
// Socket Functions
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index 1a0542c1..49cf86dfe 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
+#include <unistd.h>
#include <iterator>
#include <string>
@@ -710,6 +711,16 @@ int KernelProxy::tcsetattr(int fd, int optional_actions,
return 0;
}
+int KernelProxy::kill(pid_t pid, int sig) {
+ errno = EINVAL;
+ return -1;
+}
+
+sighandler_t KernelProxy::sigset(int signum, sighandler_t handler) {
+ errno = EINVAL;
+ return SIG_ERR;
+}
+
#ifdef PROVIDES_SOCKET_API
int KernelProxy::select(int nfds, fd_set* readfds, fd_set* writefds,
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h
index 21d68c1..6877a82 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h
@@ -12,6 +12,7 @@
#include "nacl_io/kernel_object.h"
#include "nacl_io/mount_factory.h"
#include "nacl_io/mount_socket.h"
+#include "nacl_io/ossignal.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/ostypes.h"
#include "nacl_io/osutime.h"
@@ -125,6 +126,9 @@ class KernelProxy : protected KernelObject {
virtual int tcsetattr(int fd, int optional_actions,
const struct termios *termios_p);
+ virtual int kill(pid_t pid, int sig);
+ virtual sighandler_t sigset(int signum, sighandler_t handler);
+
#ifdef PROVIDES_SOCKET_API
virtual int select(int nfds, fd_set* readfds, fd_set* writefds,
fd_set* exceptfds, struct timeval* timeout);
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h b/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
index 33a4c2d..c7f8ce1 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
@@ -5,9 +5,11 @@
#ifndef LIBRARIES_NACL_IO_KERNEL_WRAP_H_
#define LIBRARIES_NACL_IO_KERNEL_WRAP_H_
-#include <sys/types.h>
+#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
#include "nacl_io/ossocket.h"
#include "nacl_io/ostypes.h"
@@ -62,7 +64,6 @@ int ftruncate(int fd, off_t length) NOTHROW;
char* NAME(getcwd)(char* buf, getcwd_size_t size) NOTHROW;
char* getwd(char* buf) NOTHROW;
int getdents(int fd, void* buf, unsigned int count) NOTHROW;
-int ioctl(int d, int request, char* argp) NOTHROW;
int NAME(isatty)(int fd) NOTHROW;
int lchown(const char* path, uid_t owner, gid_t group) NOTHROW;
int link(const char* oldpath, const char* newpath) NOTHROW;
@@ -81,6 +82,7 @@ int NAME(open)(const char* path, int oflag, ...);
read_ssize_t NAME(read)(int fd, void* buf, size_t nbyte);
int remove(const char* path) NOTHROW;
int NAME(rmdir)(const char* path) NOTHROW;
+sighandler_t sigset(int sig, sighandler_t disp);
#if defined(WIN32)
int setenv(const char* name, const char* value, int overwrite);
int _stat32(const char* path, struct _stat32* buf);
diff --git a/native_client_sdk/src/libraries/nacl_io/library.dsc b/native_client_sdk/src/libraries/nacl_io/library.dsc
index 0785a53..acd2ba8 100644
--- a/native_client_sdk/src/libraries/nacl_io/library.dsc
+++ b/native_client_sdk/src/libraries/nacl_io/library.dsc
@@ -68,6 +68,7 @@
"syscalls/inet_ntop.cc",
"syscalls/ioctl.c",
"syscalls/isatty.c",
+ "syscalls/kill.c",
"syscalls/lchown.c",
"syscalls/link.c",
"syscalls/listen.c",
@@ -90,6 +91,8 @@
"syscalls/sendto.c",
"syscalls/setsockopt.c",
"syscalls/shutdown.c",
+ "syscalls/signal.c",
+ "syscalls/sigset.c",
"syscalls/socket.c",
"syscalls/socketpair.c",
"syscalls/unlink.c",
@@ -137,6 +140,7 @@
"osdirent.h",
"osinttypes.h",
"osmman.h",
+ "ossignal.h",
"ossocket.h",
"osstat.h",
"ostime.h",
@@ -161,8 +165,10 @@
"netinet/tcp.h",
"netinet6/in6.h",
"poll.h",
+ "sys/ioctl.h",
"sys/mount.h",
"sys/select.h",
+ "sys/signal.h",
"sys/socket.h",
"sys/termios.h",
"sys/utsname.h",
@@ -177,8 +183,10 @@
"netinet/tcp.h",
"netinet6/in6.h",
"poll.h",
+ "sys/ioctl.h",
"sys/mount.h",
"sys/select.h",
+ "sys/signal.h",
"sys/socket.h",
"sys/termios.h",
"sys/utsname.h",
diff --git a/native_client_sdk/src/libraries/nacl_io/ossignal.h b/native_client_sdk/src/libraries/nacl_io/ossignal.h
new file mode 100644
index 0000000..3ce0071
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/ossignal.h
@@ -0,0 +1,17 @@
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+#ifndef LIBRARIES_NACL_IO_OSSIGNAL_H_
+#define LIBRARIES_NACL_IO_OSSIGNAL_H_
+
+#ifdef __native_client__
+#include <signal.h>
+#ifdef __GLIBC__
+typedef __sighandler_t sighandler_t;
+#else
+typedef _sig_func_ptr sighandler_t;
+#endif
+#endif
+
+#endif
diff --git a/native_client_sdk/src/libraries/nacl_io/syscalls/ioctl.c b/native_client_sdk/src/libraries/nacl_io/syscalls/ioctl.c
index dd23530..c1cd7d0 100644
--- a/native_client_sdk/src/libraries/nacl_io/syscalls/ioctl.c
+++ b/native_client_sdk/src/libraries/nacl_io/syscalls/ioctl.c
@@ -2,9 +2,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
+#include <stdarg.h>
+
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_wrap.h"
-int ioctl(int d, int request, char* argp) {
- return ki_ioctl(d, request, argp);
+int ioctl(int fd, unsigned long request, ...) {
+ va_list ap;
+ va_start(ap, request);
+ char* arg = va_arg(ap, char*);
+ va_end(ap);
+ return ki_ioctl(fd, request, arg);
}
diff --git a/native_client_sdk/src/libraries/nacl_io/syscalls/kill.c b/native_client_sdk/src/libraries/nacl_io/syscalls/kill.c
new file mode 100644
index 0000000..9631516
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/syscalls/kill.c
@@ -0,0 +1,10 @@
+/* Copyright 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+#include "nacl_io/kernel_intercept.h"
+#include "nacl_io/kernel_wrap.h"
+
+int kill(pid_t pid, int sig) {
+ return ki_kill(pid, sig);
+}
diff --git a/native_client_sdk/src/libraries/nacl_io/syscalls/signal.c b/native_client_sdk/src/libraries/nacl_io/syscalls/signal.c
new file mode 100644
index 0000000..a111add
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/syscalls/signal.c
@@ -0,0 +1,10 @@
+/* Copyright 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+#include "nacl_io/kernel_intercept.h"
+#include "nacl_io/kernel_wrap.h"
+
+sighandler_t signal(int signum, sighandler_t handler) {
+ return ki_signal(signum, handler);
+}
diff --git a/native_client_sdk/src/libraries/nacl_io/syscalls/sigset.c b/native_client_sdk/src/libraries/nacl_io/syscalls/sigset.c
new file mode 100644
index 0000000..258c495
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/syscalls/sigset.c
@@ -0,0 +1,10 @@
+/* Copyright 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+#include "nacl_io/kernel_intercept.h"
+#include "nacl_io/kernel_wrap.h"
+
+sighandler_t sigset(int signum, sighandler_t handler) {
+ return ki_sigset(signum, handler);
+}
diff --git a/native_client_sdk/src/libraries/third_party/newlib-extras/sys/signal.h b/native_client_sdk/src/libraries/third_party/newlib-extras/sys/signal.h
new file mode 100644
index 0000000..36093b6
--- /dev/null
+++ b/native_client_sdk/src/libraries/third_party/newlib-extras/sys/signal.h
@@ -0,0 +1,311 @@
+/* sys/signal.h */
+
+#ifndef _SYS_SIGNAL_H
+#define _SYS_SIGNAL_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "_ansi.h"
+#include <sys/features.h>
+#include <sys/types.h>
+
+/* #ifndef __STRICT_ANSI__*/
+
+typedef unsigned long sigset_t;
+
+#if defined(__rtems__)
+
+#if defined(_POSIX_REALTIME_SIGNALS)
+
+/* sigev_notify values
+ NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
+
+#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */
+ /* when the event of interest occurs. */
+#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */
+ /* value, shall be delivered when the event of */
+ /* interest occurs. */
+#define SIGEV_THREAD 3 /* A notification function shall be called to */
+ /* perform notification. */
+
+/* Signal Generation and Delivery, P1003.1b-1993, p. 63
+ NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
+ sigev_notify_attributes to the sigevent structure. */
+
+union sigval {
+ int sival_int; /* Integer signal value */
+ void *sival_ptr; /* Pointer signal value */
+};
+
+struct sigevent {
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union sigval sigev_value; /* Signal value */
+
+#if defined(_POSIX_THREADS)
+ void (*sigev_notify_function)( union sigval );
+ /* Notification function */
+ pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */
+#endif
+};
+
+/* Signal Actions, P1003.1b-1993, p. 64 */
+/* si_code values, p. 66 */
+
+#define SI_USER 1 /* Sent by a user. kill(), abort(), etc */
+#define SI_QUEUE 2 /* Sent by sigqueue() */
+#define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */
+#define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */
+#define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */
+
+typedef struct {
+ int si_signo; /* Signal number */
+ int si_code; /* Cause of the signal */
+ union sigval si_value; /* Signal value */
+} siginfo_t;
+#endif
+
+/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
+
+#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */
+#define SA_SIGINFO 2 /* Invoke the signal catching function with */
+ /* three arguments instead of one. */
+
+/* struct sigaction notes from POSIX:
+ *
+ * (1) Routines stored in sa_handler should take a single int as
+ * their argument although the POSIX standard does not require this.
+ * This is not longer true since at least POSIX.1-2008
+ * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
+ * application should not use both simultaneously.
+ */
+
+typedef void (*_sig_func_ptr)(int);
+
+struct sigaction {
+ int sa_flags; /* Special flags to affect behavior of signal */
+ sigset_t sa_mask; /* Additional set of signals to be blocked */
+ /* during execution of signal-catching */
+ /* function. */
+ union {
+ _sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */
+#if defined(_POSIX_REALTIME_SIGNALS)
+ void (*_sigaction)( int, siginfo_t *, void * );
+#endif
+ } _signal_handlers;
+};
+
+#define sa_handler _signal_handlers._handler
+#if defined(_POSIX_REALTIME_SIGNALS)
+#define sa_sigaction _signal_handlers._sigaction
+#endif
+
+#elif defined(__CYGWIN__)
+#include <cygwin/signal.h>
+#else
+#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
+
+typedef void (*_sig_func_ptr)(int);
+
+struct sigaction
+{
+ _sig_func_ptr sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+};
+#endif /* defined(__rtems__) */
+
+#define SIG_SETMASK 0 /* set mask with sigprocmask() */
+#define SIG_BLOCK 1 /* set of signals to block */
+#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
+
+/* These depend upon the type of sigset_t, which right now
+ is always a long.. They're in the POSIX namespace, but
+ are not ANSI. */
+#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
+#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
+#define sigemptyset(what) (*(what) = 0, 0)
+#define sigfillset(what) (*(what) = ~(0), 0)
+#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
+
+int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
+
+#if defined(_POSIX_THREADS)
+int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
+#endif
+
+/* protos for functions found in winsup sources for CYGWIN */
+#if defined(__CYGWIN__) || defined(__rtems__) || defined (__native_client__)
+#undef sigaddset
+#undef sigdelset
+#undef sigemptyset
+#undef sigfillset
+#undef sigismember
+
+int _EXFUN(kill, (pid_t, int));
+int _EXFUN(killpg, (pid_t, int));
+int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
+int _EXFUN(sigaddset, (sigset_t *, const int));
+int _EXFUN(sigdelset, (sigset_t *, const int));
+int _EXFUN(sigismember, (const sigset_t *, int));
+int _EXFUN(sigfillset, (sigset_t *));
+int _EXFUN(sigemptyset, (sigset_t *));
+int _EXFUN(sigpending, (sigset_t *));
+int _EXFUN(sigsuspend, (const sigset_t *));
+int _EXFUN(sigpause, (int));
+
+#if defined(_POSIX_THREADS)
+#ifdef __CYGWIN__
+# ifndef _CYGWIN_TYPES_H
+# error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib.
+# endif
+#endif
+int _EXFUN(pthread_kill, (pthread_t thread, int sig));
+#endif
+
+#if defined(_POSIX_REALTIME_SIGNALS)
+
+/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
+ NOTE: P1003.1c/D10, p. 39 adds sigwait(). */
+
+int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
+int _EXFUN(sigtimedwait,
+ (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
+);
+int _EXFUN(sigwait, (const sigset_t *set, int *sig));
+
+/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
+int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
+
+#endif /* defined(_POSIX_REALTIME_SIGNALS) */
+
+#endif /* defined(__CYGWIN__) || defined(__rtems__) */
+
+/* #endif __STRICT_ANSI__ */
+
+#if defined(___AM29K__)
+/* These all need to be defined for ANSI C, but I don't think they are
+ meaningful. */
+#define SIGABRT 1
+#define SIGFPE 1
+#define SIGILL 1
+#define SIGINT 1
+#define SIGSEGV 1
+#define SIGTERM 1
+/* These need to be defined for POSIX, and some others do too. */
+#define SIGHUP 1
+#define SIGQUIT 1
+#define NSIG 2
+#elif defined(__GO32__)
+#define SIGINT 1
+#define SIGKILL 2
+#define SIGPIPE 3
+#define SIGFPE 4
+#define SIGHUP 5
+#define SIGTERM 6
+#define SIGSEGV 7
+#define SIGTSTP 8
+#define SIGQUIT 9
+#define SIGTRAP 10
+#define SIGILL 11
+#define SIGEMT 12
+#define SIGALRM 13
+#define SIGBUS 14
+#define SIGLOST 15
+#define SIGSTOP 16
+#define SIGABRT 17
+#define SIGUSR1 18
+#define SIGUSR2 19
+#define NSIG 20
+#elif !defined(SIGTRAP)
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGIOT 6 /* IOT instruction */
+#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
+#define SIGEMT 7 /* EMT instruction */
+#define SIGFPE 8 /* floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGSEGV 11 /* segmentation violation */
+#define SIGSYS 12 /* bad argument to system call */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
+
+#if defined(__rtems__)
+#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGCLD 20 /* System V name for SIGCHLD */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGPOLL SIGIO /* System V name for SIGIO */
+#define SIGWINCH 24 /* window changed */
+#define SIGUSR1 25 /* user defined signal 1 */
+#define SIGUSR2 26 /* user defined signal 2 */
+
+/* Real-Time Signals Range, P1003.1b-1993, p. 61
+ NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
+ (which is a minimum of 8) signals.
+ */
+#define SIGRTMIN 27
+#define SIGRTMAX 31
+#define __SIGFIRSTNOTRT SIGHUP
+#define __SIGLASTNOTRT SIGUSR2
+
+#define NSIG 32 /* signal 0 implied */
+
+#elif defined(__svr4__)
+/* svr4 specifics. different signals above 15, and sigaction. */
+#define SIGUSR1 16
+#define SIGUSR2 17
+#define SIGCLD 18
+#define SIGPWR 19
+#define SIGWINCH 20
+#define SIGPOLL 22 /* 20 for x.out binaries!!!! */
+#define SIGSTOP 23 /* sendable stop signal not from tty */
+#define SIGTSTP 24 /* stop signal from tty */
+#define SIGCONT 25 /* continue a stopped process */
+#define SIGTTIN 26 /* to readers pgrp upon background tty read */
+#define SIGTTOU 27 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define NSIG 28
+#else
+#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGCLD 20 /* System V name for SIGCHLD */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGPOLL SIGIO /* System V name for SIGIO */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window changed */
+#define SIGLOST 29 /* resource lost (eg, record-lock lost) */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
+#define NSIG 32 /* signal 0 implied */
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef _SIGNAL_H_
+/* Some applications take advantage of the fact that <sys/signal.h>
+ * and <signal.h> are equivalent in glibc. Allow for that here. */
+#include <signal.h>
+#endif
+#endif /* _SYS_SIGNAL_H */
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h
index 159e3cb..8a301ac 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h
@@ -10,6 +10,7 @@
#include "gmock/gmock.h"
#include "nacl_io/kernel_proxy.h"
+#include "nacl_io/ossignal.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/ostermios.h"
@@ -34,25 +35,28 @@ class KernelProxyMock : public nacl_io::KernelProxy {
MOCK_METHOD1(getwd, char*(char*));
MOCK_METHOD3(ioctl, int(int, int, char*));
MOCK_METHOD1(isatty, int(int));
+ MOCK_METHOD2(kill, int(int, int));
MOCK_METHOD3(lchown, int(const char*, uid_t, gid_t));
+ MOCK_METHOD2(link, int(const char*, const char*));
MOCK_METHOD3(lseek, off_t(int, off_t, int));
MOCK_METHOD2(mkdir, int(const char*, mode_t));
+ MOCK_METHOD6(mmap, void*(void*, size_t, int, int, int, size_t));
MOCK_METHOD5(mount, int(const char*, const char*, const char*, unsigned long,
const void*));
MOCK_METHOD2(open, int(const char*, int));
MOCK_METHOD3(read, ssize_t(int, void*, size_t));
MOCK_METHOD1(remove, int(const char*));
MOCK_METHOD1(rmdir, int(const char*));
+ MOCK_METHOD2(signal, sighandler_t(int, sighandler_t));
+ MOCK_METHOD2(sigset, sighandler_t(int, sighandler_t));
MOCK_METHOD2(stat, int(const char*, struct stat*));
+ MOCK_METHOD2(symlink, int(const char*, const char*));
MOCK_METHOD2(tcgetattr, int(int, struct termios*));
MOCK_METHOD3(tcsetattr, int(int, int, const struct termios*));
MOCK_METHOD1(umount, int(const char*));
MOCK_METHOD1(unlink, int(const char*));
MOCK_METHOD2(utime, int(const char*, const struct utimbuf*));
MOCK_METHOD3(write, ssize_t(int, const void*, size_t));
- MOCK_METHOD2(link, int(const char*, const char*));
- MOCK_METHOD2(symlink, int(const char*, const char*));
- MOCK_METHOD6(mmap, void*(void*, size_t, int, int, int, size_t));
MOCK_METHOD1(open_resource, int(const char*));
#ifdef PROVIDES_SOCKET_API
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
index bcbf147..4472d8c 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
@@ -213,6 +213,11 @@ TEST_F(KernelWrapTest, isatty) {
isatty(678);
}
+TEST_F(KernelWrapTest, kill) {
+ EXPECT_CALL(mock, kill(22, 33)).Times(1);
+ kill(22, 33);
+}
+
TEST_F(KernelWrapTest, lchown) {
uid_t uid = kDummyUid;
gid_t gid = kDummyGid;
@@ -262,6 +267,19 @@ TEST_F(KernelWrapTest, rmdir) {
rmdir("rmdir");
}
+static void handler(int) {
+}
+
+TEST_F(KernelWrapTest, sigset) {
+ EXPECT_CALL(mock, sigset(22, handler)).Times(1);
+ sigset(22, handler);
+}
+
+TEST_F(KernelWrapTest, signal) {
+ EXPECT_CALL(mock, sigset(22, handler)).Times(1);
+ signal(22, handler);
+}
+
TEST_F(KernelWrapTest, stat) {
struct stat in_statbuf;
MakeDummyStatbuf(&in_statbuf);