📄 shlock.1
字号:
.\" $Revision: 1.7 $.TH SHLOCK 1.SH NAMEshlock \- create lock files for use in shell scripts.SH SYNOPSIS.B shlock.BI \-p " pid".BI \-f " name"[.B \-b][.B \-u][.B \-c].SH DESCRIPTION.I Shlocktries to create a lock file named.I nameand write the process ID.I pidinto it.If the file already exists,.I shlockwill read the process ID from the file and test to see if the processis currently running.If the process exists, then the file will not be created..PP.I Shlockexits with a zero status if it was able to create the lock file, ornon-zero if the file refers to currently-active process..PPProcess IDs are normally read and written in ASCII.If the ``\-b'' flag is used, then they will be written as a binary.IR int .For compatibility with other systems, the ``\-u'' flag is accepted asa synonym for ``\-b'' since binary locks are used by many UUCP packages..PPThe following example shows how.I shlockwould be used within a shell script:.RS.nf.\" =()<LOCK=@<_PATH_LOCKS>@/LOCK.send>()=LOCK=/var/spool/news/data/LOCK.sendtrap 'rm -f ${LOCK} ; exit 1' 1 2 3 15if shlock -p $$ -f ${LOCK} ; then # Do appropriate workelse echo Locked by `cat ${LOCK}`f\&i.fi.RE.PPIf the ``\-c'' flag is used, then.I shlockwill not create a lock file, but will instead use the file to see ifthe lock is held be another program.If the lock is valid, the program will exit with a non-zero status; ifthe lock is not valid (i.e., invoking.I shlockwithout the flag would have succeeded), then the program will exitwith a zero status..SH HISTORYWritten by Rich $alz <rsalz@uunet.uu.net> after a description of HDB UUCPlocking given by Peter Honeyman..de R$This is revision \\$3, dated \\$4....R$ $Id: shlock.1,v 1.7 1993/01/29 16:43:15 rsalz Exp $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -