Skip to content

Commit ff6f4e7

Browse files
committed
minor bug fixes
1 parent b4be443 commit ff6f4e7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

daemonize.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import os except sleep
22
import posix, parseutils
3-
include system/ansi_c
3+
44
## This library makes your code run as a daemon process on Unix-like systems.
55

66
var
77
pid: Pid
88
pidFileInner: string
99
fi, fo, fe: File
1010

11+
proc c_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {.importc: "signal", header: "<signal.h>".}
12+
1113
proc onStop(sig: cint) {.noconv.} =
1214
close(fi)
1315
close(fo)
@@ -16,7 +18,7 @@ proc onStop(sig: cint) {.noconv.} =
1618

1719
quit(QuitSuccess)
1820

19-
template daemonize*(pidfile, si, so, se: string, body: stmt): expr =
21+
template daemonize*(pidfile, si, so, se: string, body: stmt): stmt {.immediate.} =
2022
## deamonizer
2123
##
2224
## pidfile: path to file where pid will be stored
@@ -63,8 +65,6 @@ template daemonize*(pidfile, si, so, se: string, body: stmt): expr =
6365
pid = getpid()
6466
writeFile(pidfile, $pid)
6567

66-
c_free(addr pid)
67-
6868
body
6969

7070
when isMainModule:

daemonize.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Package]
22
name = "daemonize"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
author = "Huy Doan"
55
description = "This library makes your code run as a daemon process on Unix-like systems"
66
license = "MIT"

0 commit comments

Comments
 (0)