tosprocterminate.nim 498 B

1234567891011121314151617181920212223242526
  1. discard """
  2. outputsub: "SUCCESS"
  3. """
  4. import os, osproc
  5. when defined(Windows):
  6. const ProgramWhichDoesNotEnd = "notepad"
  7. else:
  8. const ProgramWhichDoesNotEnd = "/bin/sh"
  9. echo("starting " & ProgramWhichDoesNotEnd)
  10. var process = startProcess(ProgramWhichDoesNotEnd)
  11. sleep(500)
  12. echo("stopping process")
  13. process.terminate()
  14. var TimeToWait = 5000
  15. while process.running() and TimeToWait > 0:
  16. sleep(100)
  17. TimeToWait = TimeToWait - 100
  18. if process.running():
  19. echo("FAILED")
  20. else:
  21. echo("SUCCESS")