blob: 7fc1461dd52d7f3c394248c4011d86dbfb2b6829 (
plain) (
tree)
|
|
import std/posix
proc closeHandle(fd, flags: cint) =
let devnull = open("/dev/null", flags)
doAssert devnull != -1
if devnull != fd:
discard dup2(devnull, fd)
discard close(devnull)
proc closeStdin*() =
closeHandle(0, O_RDONLY)
proc closeStdout*() =
closeHandle(1, O_WRONLY)
proc closeStderr*() =
closeHandle(2, O_WRONLY)
|