# man > setlock(8)

[_setlock_(8)](https://www.chedong.com/phpMan.php/man/setlock/8/markdown)                             System Manager's Manual                            [_setlock_(8)](https://www.chedong.com/phpMan.php/man/setlock/8/markdown)

## NAME
       setlock - runs another program with a file locked.

## SYNOPSIS
       **setlock **[ **-nNxX **] _fn_ _child_

## DESCRIPTION
       _fn_ is a single argument.  _child_ consists of one or more arguments.

       **setlock **opens _fn_ for writing (creating it if it does not exist), obtains an exclusive lock on
       it, and runs _child_.

       Normally the lock disappears when _child_ exits.

       Here's  the  complete  story:  _child_ is given a descriptor for a locked ofile pointing to the
       disk file named _fn_.  The lock disappears when this ofile is

       o      closed by all the processes that have descriptors for it or

       o      explicitly unlocked.

## OPTIONS
### -n     

### -N     
              tain a new lock.

### -x     

### -X     
              sage and exits nonzero.

## SEE ALSO
       [supervise(8)](https://www.chedong.com/phpMan.php/man/supervise/8/markdown),   [svc(8)](https://www.chedong.com/phpMan.php/man/svc/8/markdown),   [svok(8)](https://www.chedong.com/phpMan.php/man/svok/8/markdown),  [svstat(8)](https://www.chedong.com/phpMan.php/man/svstat/8/markdown),  [svscanboot(8)](https://www.chedong.com/phpMan.php/man/svscanboot/8/markdown),  [svscan(8)](https://www.chedong.com/phpMan.php/man/svscan/8/markdown),  [readproctitle(8)](https://www.chedong.com/phpMan.php/man/readproctitle/8/markdown),
       [fghack(8)](https://www.chedong.com/phpMan.php/man/fghack/8/markdown), [pgrphack(8)](https://www.chedong.com/phpMan.php/man/pgrphack/8/markdown), [multilog(8)](https://www.chedong.com/phpMan.php/man/multilog/8/markdown), [tai64n(8)](https://www.chedong.com/phpMan.php/man/tai64n/8/markdown), [tai64nlocal(8)](https://www.chedong.com/phpMan.php/man/tai64nlocal/8/markdown),  [setuidgid(8)](https://www.chedong.com/phpMan.php/man/setuidgid/8/markdown),  [envuidgid(8)](https://www.chedong.com/phpMan.php/man/envuidgid/8/markdown),
       [envdir(8)](https://www.chedong.com/phpMan.php/man/envdir/8/markdown), [softlimit(8)](https://www.chedong.com/phpMan.php/man/softlimit/8/markdown)

       <http://cr.yp.to/daemontools.html>

                                                                                          [_setlock_(8)](https://www.chedong.com/phpMan.php/man/setlock/8/markdown)
