tclose.nim 514 B

12345678910111213141516171819202122232425
  1. discard """
  2. exitcode: 0
  3. """
  4. when defined(linux):
  5. import osproc, os
  6. proc countFds(): int =
  7. result = 0
  8. for i in walkDir("/proc/self/fd"):
  9. result += 1
  10. let initCount = countFds()
  11. let p = osproc.startProcess("echo", options={poUsePath})
  12. doAssert countFds() == initCount + 3
  13. p.close
  14. doAssert countFds() == initCount
  15. let p1 = osproc.startProcess("echo", options={poUsePath})
  16. discard p1.inputStream
  17. doAssert countFds() == initCount + 3
  18. p.close
  19. doAssert countFds() == initCount