]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
define signalfd patch
authorMichael K. Johnson <johnsonm@rpath.com>
Sun, 8 Mar 2009 16:24:26 +0000 (17:24 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Sun, 8 Mar 2009 16:24:26 +0000 (17:24 +0100)
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 <johnsonm@rpath.com>
Signed-off-by: Daniel Lezcnao <dlezcano@fr.ibm.com>
src/lxc/start.c

index cb32261003db0ec345284106ac7f7b4b614c06d6..410235c21c38f7ee9d1aaf3d40f5664a10231bab 100644 (file)
 #include <sys/poll.h>
 
 #ifdef HAVE_SYS_SIGNALFD_H 
-#include <sys/signalfd.h>
+#  include <sys/signalfd.h>
 #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