A clone of btpd with my configuration changes.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

63 lignes
958 B

  1. /*
  2. * Compile with:
  3. * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent
  4. */
  5. #include <sys/types.h>
  6. #ifdef HAVE_CONFIG_H
  7. #include "config.h"
  8. #endif
  9. #include <sys/stat.h>
  10. #ifndef WIN32
  11. #include <sys/queue.h>
  12. #include <unistd.h>
  13. #include <sys/time.h>
  14. #else
  15. #include <windows.h>
  16. #endif
  17. #include <signal.h>
  18. #include <fcntl.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <errno.h>
  23. #include <event.h>
  24. int called = 0;
  25. void
  26. signal_cb(int fd, short event, void *arg)
  27. {
  28. struct event *signal = arg;
  29. printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal));
  30. if (called >= 2)
  31. event_del(signal);
  32. called++;
  33. }
  34. int
  35. main (int argc, char **argv)
  36. {
  37. struct event signal_int;
  38. /* Initalize the event library */
  39. event_init();
  40. /* Initalize one event */
  41. event_set(&signal_int, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb,
  42. &signal_int);
  43. event_add(&signal_int, NULL);
  44. event_dispatch();
  45. return (0);
  46. }