Skip to content

Commit

Permalink
Merge pull request #1 from kevingolding2001/v0.20
Browse files Browse the repository at this point in the history
Changes required to compile under Nim v0.20
  • Loading branch information
ba0f3 authored Jun 25, 2019
2 parents 49ac2e2 + 8af3921 commit e1107aa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions daemonize.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ proc onStop(sig: cint) {.noconv.} =

quit(QuitSuccess)

template daemonize*(pidfile, si, so, se, cd: string,body: stmt): stmt {.immediate.} =
template daemonize*(pidfile, si, so, se, cd: string,body: typed): void =
## deamonizer
##
## pidfile: path to file where pid will be stored
Expand All @@ -35,7 +35,7 @@ template daemonize*(pidfile, si, so, se, cd: string,body: stmt): stmt {.immediat
if pid > 0:
quit(QuitSuccess)

if not isNilorEmpty(cd):
if not cd.len == 0:
discard chdir(cd)
discard setsid()
discard umask(0)
Expand All @@ -47,15 +47,15 @@ template daemonize*(pidfile, si, so, se, cd: string,body: stmt): stmt {.immediat
flushFile(stdout)
flushFile(stderr)

if not si.isNil and si != "":
if not si.len == 0:
fi = open(si, fmRead)
discard dup2(getFileHandle(fi), getFileHandle(stdin))

if not so.isNil and so != "":
if not so.len == 0:
fo = open(so, fmAppend)
discard dup2(getFileHandle(fo), getFileHandle(stdout))

if not se.isNil and se != "":
if not se.len == 0:
fe = open(se, fmAppend)
discard dup2(getFileHandle(fe), getFileHandle(stderr))

Expand Down

0 comments on commit e1107aa

Please sign in to comment.