texitsignal.nim 882 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. discard """
  2. output: '''true
  3. true'''
  4. targets: "c"
  5. """
  6. import os, osproc
  7. when not defined(windows):
  8. import posix
  9. # Checks that the environment is passed correctly in startProcess
  10. # To do that launches a copy of itself with a new environment.
  11. if paramCount() == 0:
  12. # Parent process
  13. let p = startProcess(
  14. getAppFilename(),
  15. args = @["child"],
  16. options = {poStdErrToStdOut, poUsePath, poParentStreams}
  17. )
  18. echo p.running()
  19. p.kill()
  20. when defined(windows):
  21. # windows kill happens using TerminateProcess(h, 0), so we should get a
  22. # 0 here
  23. echo p.waitForExit() == 0
  24. elif defined(haiku):
  25. # on Haiku, the program main thread receive SIGKILLTHR
  26. echo p.waitForExit() == 128 + SIGKILLTHR
  27. else:
  28. # on posix (non-windows), kill sends SIGKILL
  29. echo p.waitForExit() == 128 + SIGKILL
  30. else:
  31. sleep(5000) # should get killed before this