关于kill -0 pid的作用( 二 )


shell脚本中示例:
#!/bin/bashPIDFILE=$1if [ -f $PIDFILE ]; thenPID="$(cat $PIDFILE)"if kill -0 "$PID" &> /dev/null; thenecho "process is exists"exit 0elseecho "process is not exists"exit 5fifiGo代码中示例:
func processExists(pid int) bool { if err := syscall.Kill(pid, 0); err == nil {return true } else {return false }}
【关于kill -0 pid的作用】


推荐阅读