我得到一段 PID 文件控制的代码。
程序员的风格,看不懂。。
我不知道-->
&& 的使用
[[ $mypid -ne $procpid ]] **&&**
并正确地重新启动自己(在 MacosX 上不起作用)
$0 $@ &
代码完成...
function createpidfile() {
mypid=$1
pidfile=$2
#Close stderr, don't overwrite existing file, shove my pid in the lock file.
$(exec 2>&-; set -o noclobber; echo "$mypid" > "$pidfile")
[[ ! -f "$pidfile" ]] && exit #Lock file creation failed
procpid=$(<"$pidfile")
[[ $mypid -ne $procpid ]] && {
#I'm not the pid in the lock file
# Is the process pid in the lockfile still running?
isrunning "$pidfile" || {
# No. Kill the pidfile and relaunch ourselves properly.
rm "$pidfile"
$0 $@ &
}
exit
}
}
我迷路了