浏览代码

make pkg pidfile support darwin

Signed-off-by: allencloud <allen.sun@daocloud.io>
allencloud 9 年之前
父节点
当前提交
a91f59d487
共有 2 个文件被更改,包括 19 次插入1 次删除
  1. 18 0
      pkg/pidfile/pidfile_darwin.go
  2. 1 1
      pkg/pidfile/pidfile_unix.go

+ 18 - 0
pkg/pidfile/pidfile_darwin.go

@@ -0,0 +1,18 @@
+// +build darwin
+
+package pidfile
+
+import (
+	"syscall"
+)
+
+func processExists(pid int) bool {
+	// OS X does not have a proc filesystem.
+	// Use kill -0 pid to judge if the process exists.
+	err := syscall.Kill(pid, 0)
+	if err != nil {
+		return false
+	}
+
+	return true
+}

+ 1 - 1
pkg/pidfile/pidfile_unix.go

@@ -1,4 +1,4 @@
-// +build !windows
+// +build !windows,!darwin
 
 package pidfile