test-child.c 929 B

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