Signed-off-by: allencloud <allen.sun@daocloud.io>
allencloud authored on 2016/08/01 21:03:501 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,18 @@ |
0 |
+// +build darwin |
|
1 |
+ |
|
2 |
+package pidfile |
|
3 |
+ |
|
4 |
+import ( |
|
5 |
+ "syscall" |
|
6 |
+) |
|
7 |
+ |
|
8 |
+func processExists(pid int) bool { |
|
9 |
+ // OS X does not have a proc filesystem. |
|
10 |
+ // Use kill -0 pid to judge if the process exists. |
|
11 |
+ err := syscall.Kill(pid, 0) |
|
12 |
+ if err != nil { |
|
13 |
+ return false |
|
14 |
+ } |
|
15 |
+ |
|
16 |
+ return true |
|
17 |
+} |