test-sig.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * This file is part of Quagga.
  3. *
  4. * Quagga is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2, or (at your option) any
  7. * later version.
  8. *
  9. * Quagga is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with Quagga; see the file COPYING. If not, write to the Free
  16. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  17. * 02111-1307, USA.
  18. */
  19. #include <zebra.h>
  20. #include <sigevent.h>
  21. #include "lib/log.h"
  22. #include "lib/memory.h"
  23. static void
  24. sighup (void)
  25. {
  26. printf ("processed hup\n");
  27. }
  28. static void
  29. sigusr1 (void)
  30. {
  31. printf ("processed usr1\n");
  32. }
  33. static void
  34. sigusr2 (void)
  35. {
  36. printf ("processed usr2\n");
  37. }
  38. struct quagga_signal_t sigs[] =
  39. {
  40. {
  41. .signal = SIGHUP,
  42. .handler = &sighup,
  43. },
  44. {
  45. .signal = SIGUSR1,
  46. .handler = &sigusr1,
  47. },
  48. {
  49. .signal = SIGUSR2,
  50. .handler = &sigusr2,
  51. }
  52. };
  53. struct thread_master *master;
  54. int
  55. main (void)
  56. {
  57. master = thread_master_create ();
  58. signal_init (master, array_size(sigs), sigs);
  59. zlog_default = openzlog("testsig", ZLOG_NONE,
  60. LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
  61. zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
  62. zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
  63. zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
  64. thread_main (master);
  65. exit (0);
  66. }