1 /* vi: set sw=4 ts=4 sts=4: */
3 * signalfd test for uClibc
4 * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com>
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
16 #include <sys/signalfd.h>
17 #include <sys/fcntl.h>
22 int fd, ret, result = 0;
23 struct signalfd_siginfo ssi;
27 sigaddset(&mask, SIGUSR1);
28 sigprocmask(SIG_BLOCK, &mask, NULL);
30 fd = signalfd(-1, &mask, SFD_NONBLOCK);
32 printf("signalfd() failed: %s\n", strerror(errno));
36 /* this should return immediately with EAGAIN due to SFD_NONBLOCK */
37 memset(&ssi, 0, sizeof(ssi));
38 ret = read(fd, &ssi, sizeof(ssi));
39 if (ret != -1 || errno != EAGAIN) {
40 error(0, 0, "first read() returned %d", ret);
44 kill(getpid(), SIGUSR1);
46 /* this should return a struct ssi indicating receipt of SIGUSR1 */
47 ret = read(fd, &ssi, sizeof(ssi));
48 if (ret != sizeof(ssi)) {
49 error(0, 0, "second read() returned %d", ret);
53 if (ssi.ssi_signo != SIGUSR1) {
54 error(0, 0, "ssi contains bogus signo");
62 #define TEST_FUNCTION do_test ()
63 #include "../test-skeleton.c"