C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
_locking
 Summary Example                         Up Contents Index Back
─────Run-Time Library──────────────────────────────────────────────────────
 
     The _locking function locks or unlocks <nbyte> bytes of the file
     specified by <handle>. Locking bytes in a file prevents access to
     those bytes by other processes in a networked or multiuser
     system.
 
     All locking or unlocking begins at the current position of the
     file pointer and proceeds for the next <nbyte> bytes, or to the
     end of the file. It is possible to lock bytes past the end of the
     file.
 
     The <mode> argument specifies the locking action to be performed.
     It must be one of the following manifest constants:
 
     _LK_LOCK      _LK_NRBLCK     _LK_UNLCK
     _LK_NBLCK     _LK_RLCK
 
     More than one region of a file can be locked, but no overlapping
     regions are allowed.
 
     When a region of a file is unlocked, it must correspond to a
     region that was previously locked. The _locking function does not
     merge adjacent regions; if two locked regions are adjacent, each
     region must be unlocked separately.
 
     Regions should be locked only briefly and should be unlocked
     before closing a file or exiting the program.
 
     The _locking function should be used only with DOS versions 3.0 or
     later; it has no effect under earlier versions of DOS. Note that
     under DOS versions 3.0 and 3.1, the files locked by a parent
     process may become unlocked when one of its children exits.
 
     File sharing must be loaded to use the locking function. Under DOS
     versions 3.0 and higher, you may need to use the SHARE program
     provided with DOS to enable file sharing. Check documentation for
     your networking software and the DOS SHARE program for details.
 
     Return Value
 
     The _locking function returns 0 if it is successful. A return
     value of -1 indicates failure, and errno is set to EACCES, EBADF,
     EDEADLOCK, or EINVAL.
                                    -♦-