test-child.c 843 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <stdio.h>
  2. #include "orconfig.h"
  3. #ifdef MS_WINDOWS
  4. #define WINDOWS_LEAN_AND_MEAN
  5. #include <windows.h>
  6. #else
  7. #include <unistd.h>
  8. #endif
  9. /** Trivial test program which prints out its command line arguments so we can
  10. * check if tor_spawn_background() works */
  11. int
  12. main(int argc, char **argv)
  13. {
  14. int i;
  15. fprintf(stdout, "OUT\n");
  16. fprintf(stderr, "ERR\n");
  17. for (i = 1; i < argc; i++)
  18. fprintf(stdout, "%s\n", argv[i]);
  19. fprintf(stdout, "SLEEPING\n");
  20. /* We need to flush stdout so that test_util_spawn_background_partial_read()
  21. succeed. Otherwise ReadFile() will get the entire output in one */
  22. // XXX: Can we make stdio flush on newline?
  23. fflush(stdout);
  24. #ifdef MS_WINDOWS
  25. Sleep(1000);
  26. #else
  27. sleep(1);
  28. #endif
  29. fprintf(stdout, "DONE\n");
  30. #ifdef MS_WINDOWS
  31. Sleep(1000);
  32. #else
  33. sleep(1);
  34. #endif
  35. return 0;
  36. }