From 8ca61733b993c12229cdab2b9c35fe2e4d46b9ba Mon Sep 17 00:00:00 2001 From: "Michael K. Johnson" Date: Sun, 8 Mar 2009 17:24:26 +0100 Subject: [PATCH] define signalfd patch If sys/signalfd.h does not exist, assume that it does not exist in glibc, rather than that it exists without a corresponding header file. Note that this version of the signalfd() wrapper function (unlike the version in glibc) falls back dynamically to the old signalfd system call if the signalfd4 system call is not implemented in the currently-running kernel; the version in glibc chooses the version of the signalfd system call to make via static build-time configuration. Signed-off-by: Michael K Johnson Signed-off-by: Daniel Lezcnao --- src/lxc/start.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/lxc/start.c b/src/lxc/start.c index cb3226100..410235c21 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -43,9 +43,35 @@ #include #ifdef HAVE_SYS_SIGNALFD_H -#include +# include #else -extern int signalfd (int fd, const sigset_t *mask, int flags); +# ifndef __NR_signalfd4 +/* assume kernel headers are too old */ +# if __i386__ +# define __NR_signalfd4 327 +# elif __x86_64__ +# define __NR_signalfd4 289 +# endif +#endif + +# ifndef __NR_signalfd +/* assume kernel headers are too old */ +# if __i386__ +# define __NR_signalfd 321 +# elif __x86_64__ +# define __NR_signalfd 282 +# endif +#endif + +int signalfd(int fd, const sigset_t *mask, int flags) +{ + int retval; + + retval = syscall (__NR_signalfd4, fd, mask, _NSIG / 8, flags); + if (errno == ENOSYS && flags == 0) + retval = syscall (__NR_signalfd, fd, mask, _NSIG / 8); + return retval; +} #endif #if !HAVE_DECL_PR_CAPBSET_DROP