tst-sigaction.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Test sigaction regression for BZ #23069.
  2. Copyright (C) 2018-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <signal.h>
  16. #include <unistd.h>
  17. #include <support/check.h>
  18. static void
  19. my_sig_handler (int signum)
  20. {
  21. }
  22. static int
  23. do_test (void)
  24. {
  25. /* Define a simple signal handler */
  26. struct sigaction act;
  27. act.sa_handler = my_sig_handler;
  28. act.sa_flags = 0;
  29. sigemptyset (&act.sa_mask);
  30. /* Set it as SIGUSR1 signal handler */
  31. TEST_VERIFY_EXIT (sigaction (SIGUSR1, &act, NULL) == 0);
  32. /* Get SIGUSR1 signal handler */
  33. TEST_VERIFY_EXIT (sigaction (SIGUSR1, NULL, &act) == 0);
  34. /* Check it is consistent with the defined one */
  35. TEST_VERIFY (act.sa_handler == my_sig_handler);
  36. TEST_VERIFY (!(act.sa_flags & SA_RESETHAND));
  37. for (int i = 1; i < _NSIG; i++)
  38. {
  39. TEST_VERIFY (!sigismember (&act.sa_mask, i));
  40. }
  41. return 0;
  42. }
  43. #include <support/test-driver.c>