tst-sigset.c 868 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Test sig*set functions. */
  2. #include <signal.h>
  3. #include <string.h>
  4. #include <errno.h>
  5. #include <stdio.h>
  6. #define TEST_FUNCTION do_test ()
  7. static int
  8. do_test (void)
  9. {
  10. int result = 0;
  11. int sig = -1;
  12. #define TRY(call) \
  13. if (call) \
  14. { \
  15. printf ("%s (sig = %d): %s\n", #call, sig, strerror(errno)); \
  16. result = 1; \
  17. } \
  18. else
  19. sigset_t set;
  20. TRY (sigemptyset (&set) != 0);
  21. #ifdef SIGRTMAX
  22. int max_sig = SIGRTMAX;
  23. #else
  24. int max_sig = NSIG - 1;
  25. #endif
  26. for (sig = 1; sig <= max_sig; ++sig)
  27. {
  28. TRY (sigismember (&set, sig) != 0);
  29. TRY (sigaddset (&set, sig) != 0);
  30. TRY (sigismember (&set, sig) == 0);
  31. TRY (sigdelset (&set, sig) != 0);
  32. TRY (sigismember (&set, sig) != 0);
  33. }
  34. return result;
  35. }
  36. #include "../test-skeleton.c"