test-sig.c 976 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <zebra.h>
  2. #include <sigevent.h>
  3. #include "lib/log.h"
  4. #include "lib/memory.h"
  5. void
  6. sighup (void)
  7. {
  8. printf ("processed hup\n");
  9. }
  10. void
  11. sigusr1 (void)
  12. {
  13. printf ("processed usr1\n");
  14. }
  15. void
  16. sigusr2 (void)
  17. {
  18. printf ("processed usr2\n");
  19. }
  20. struct quagga_signal_t sigs[] =
  21. {
  22. {
  23. .signal = SIGHUP,
  24. .handler = &sighup,
  25. },
  26. {
  27. .signal = SIGUSR1,
  28. .handler = &sigusr1,
  29. },
  30. {
  31. .signal = SIGUSR2,
  32. .handler = &sigusr2,
  33. }
  34. };
  35. struct thread_master *master;
  36. struct thread t;
  37. int
  38. main (void)
  39. {
  40. master = thread_master_create ();
  41. signal_init (master, array_size(sigs), sigs);
  42. zlog_default = openzlog("testsig", ZLOG_NONE,
  43. LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
  44. zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
  45. zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
  46. zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
  47. while (thread_fetch (master, &t))
  48. thread_call (&t);
  49. exit (0);
  50. }