stop.c 635 B

1234567891011121314151617181920212223242526272829303132
  1. #include <reproc/reproc.h>
  2. #include "assert.h"
  3. static void stop(REPROC_STOP action, int status)
  4. {
  5. int r = -1;
  6. reproc_t *process = reproc_new();
  7. ASSERT(process);
  8. const char *argv[] = { RESOURCE_DIRECTORY "/stop", NULL };
  9. r = reproc_start(process, argv, (reproc_options){ 0 });
  10. ASSERT_OK(r);
  11. r = reproc_wait(process, 50);
  12. ASSERT(r == REPROC_ETIMEDOUT);
  13. reproc_stop_actions stop = { .first = { action, 500 } };
  14. r = reproc_stop(process, stop);
  15. ASSERT_EQ_INT(r, status);
  16. reproc_destroy(process);
  17. }
  18. int main(void)
  19. {
  20. stop(REPROC_STOP_TERMINATE, REPROC_SIGTERM);
  21. stop(REPROC_STOP_KILL, REPROC_SIGKILL);
  22. }