.\" -*- coding: UTF-8 -*- .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) and .\" and Copyright 2002 Michael Kerrisk .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" Modified Fri Jan 31 16:26:07 1997 by Eric S. Raymond .\" Modified Fri Dec 11 17:57:27 1998 by Jamie Lokier .\" Modified 24 Apr 2002 by Michael Kerrisk .\" Substantial rewrites and additions .\" 2005-05-10 mtk, noted that lock conversions are not atomic. .\" .\" FIXME Maybe document LOCK_MAND, LOCK_RW, LOCK_READ, LOCK_WRITE .\" which only have effect for SAMBA. .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH flock 2 "4 Diciembre 2022" "Páginas de manual de Linux 6.03" .SH NOMBRE flock \- impone o elimina un bloqueo de recomendación en un archivo abierto. .SH BIBLIOTECA Biblioteca Estándar C (\fIlibc\fP, \fI\-lc\fP) .SH SINOPSIS .nf \fB#include \fP .PP \fBint flock(int \fP\fIfd\fP\fB, int \fP\fIoperation\fP\fB);\fP .fi .SH DESCRIPCIÓN Impone o elimina un bloqueo de recomendación (advisory lock) sobre el fichero abierto especificado por \fIfd\fP. El parámetro \fIoperation\fP puede tener uno de los siguientes valores: .RS 4 .TP 9 \fBLOCK_SH\fP Pone un bloqueo compartido. Más de un proceso puede tener un bloqueo compartido para un fichero en un momento dado. .TP \fBLOCK_EX\fP Pone un bloqueo exclusivo. Solamente un proceso puede tener un bloqueo exclusivo para un fichero en un momento dado. .TP \fBLOCK_UN\fP Elimina un bloqueo existente mantenido por este proceso. .RE .PP Una llamada a \fBflock\fP() puede bloquearse si otro proceso mantiene un bloqueo incompatible. Para hacer una solicitud no bloqueante, incluya \fBLOCK_NB\fP (mediante operaciones \fIOR\fP) con cualquiera de las operaciones de arriba. .PP Un fichero no puede tener simultaneamente bloqueo compartido y exclusivo. .PP Locks created by \fBflock\fP() are associated with an open file description (see \fBopen\fP(2)). This means that duplicate file descriptors (created by, for example, \fBfork\fP(2) or \fBdup\fP(2)) refer to the same lock, and this lock may be modified or released using any of these file descriptors. Furthermore, the lock is released either by an explicit \fBLOCK_UN\fP operation on any of these duplicate file descriptors, or when all such file descriptors have been closed. .PP If a process uses \fBopen\fP(2) (or similar) to obtain more than one file descriptor for the same file, these file descriptors are treated independently by \fBflock\fP(). An attempt to lock the file using one of these file descriptors may be denied by a lock that the calling process has already placed via another file descriptor. .PP Un proceso puede tener solamente un tipo de bloqueo (compartido o exclusivo) sobre un fichero. Las llamadas posteriores a \fBflock\fP() sobre un fichero ya bloqueado convertirán un bloqueo existente al nuevo modo de bloqueo. .PP Los bloqueos creados con \fBflock\fP() se preservan tras un \fBexecve\fP(2). .PP Un bloqueo compartido o exclusivo puede ponerse sobre un fichero sin importar el modo en el que fue abierto dicho fichero. .SH "VALOR DEVUELTO" En caso de éxito se devuelve cero. En caso de error se devuelve \-1, y \fIerrno\fP se configura para indicar el error. .SH ERRORES .TP \fBEBADF\fP \fIfd\fP no es un descriptor de archivos abiertos. .TP \fBEINTR\fP Mientras se esperaba por adquirir un bloqueo, la llamada fue interrumpida por la notificación de una señal atrapada por un manejador; vea \fBsignal\fP(7). .TP \fBEINVAL\fP \fIoperation\fP no es válido. .TP \fBENOLCK\fP El núcleo se quedó sin memoria para almacenar registros de bloqueos. .TP \fBEWOULDBLOCK\fP El fichero está encadenado y la bandera \fBLOCK_NB\fP ha sido elegida. TP \fBEBADF\fP \fIfd\fP no es un descriptor de fichero abierto. .SH ESTÁNDARES 4.4BSD (la llamada al sistema \fBflock\fP() apareció por primera vez en 4.2BSD). Una versión de \fBflock\fP(), posiblemente implementada en términos de \fBfcntl\fP(2), aparece en la mayoría de UNIX's. .SH NOTAS .\" E.g., according to the flock(2) man page, FreeBSD since at least 5.3 Since Linux 2.0, \fBflock\fP() is implemented as a system call in its own right rather than being emulated in the GNU C library as a call to \fBfcntl\fP(2). With this implementation, there is no interaction between the types of lock placed by \fBflock\fP() and \fBfcntl\fP(2), and \fBflock\fP() does not detect deadlock. (Note, however, that on some systems, such as the modern BSDs, \fBflock\fP() and \fBfcntl\fP(2) locks \fIdo\fP interact with one another.) .PP \fBflock\fP() coloca bloqueos de recomendación solamente; con los permisos adecuados sobre un fichero, un proceso es libre de ignorar el uso de \fBflock\fP() y realizar E/S sobre el fichero. .PP \fBflock\fP() and \fBfcntl\fP(2) locks have different semantics with respect to forked processes and \fBdup\fP(2). On systems that implement \fBflock\fP() using \fBfcntl\fP(2), the semantics of \fBflock\fP() will be different from those described in this manual page. .PP .\" Kernel 2.5.21 changed things a little: during lock conversion .\" it is now the highest priority process that will get the lock -- mtk Converting a lock (shared to exclusive, or vice versa) is not guaranteed to be atomic: the existing lock is first removed, and then a new lock is established. Between these two steps, a pending lock request by another process may be granted, with the result that the conversion either blocks, or fails if \fBLOCK_NB\fP was specified. (This is the original BSD behavior, and occurs on many other implementations.) .SS "Detalles de NFS" Up to Linux 2.6.11, \fBflock\fP() does not lock files over NFS (i.e., the scope of locks was limited to the local system). Instead, one could use \fBfcntl\fP(2) byte\-range locking, which does work over NFS, given a sufficiently recent version of Linux and a server which supports locking. .PP Since Linux 2.6.12, NFS clients support \fBflock\fP() locks by emulating them as \fBfcntl\fP(2) byte\-range locks on the entire file. This means that \fBfcntl\fP(2) and \fBflock\fP() locks \fIdo\fP interact with one another over NFS. It also means that in order to place an exclusive lock, the file must be opened for writing. .PP .\" commit 5eebde23223aeb0ad2d9e3be6590ff8bbfab0fc2 Since Linux 2.6.37, the kernel supports a compatibility mode that allows \fBflock\fP() locks (and also \fBfcntl\fP(2) byte region locks) to be treated as local; see the discussion of the \fIlocal_lock\fP option in \fBnfs\fP(5). .SS "Detalles de CIFS" A partir de la versión 5.4, \fBflock\fP() no se despliega sobre SMB. Un archivo con estos bloqueos, no aparecerá bloqueado para usuarios remotos. .PP Since Linux 5.5, \fBflock\fP() locks are emulated with SMB byte\-range locks on the entire file. Similarly to NFS, this means that \fBfcntl\fP(2) and \fBflock\fP() locks interact with one another. Another important side\-effect is that the locks are not advisory anymore: any IO on a locked file will always fail with \fBEACCES\fP when done from a separate file descriptor. This difference originates from the design of locks in the SMB protocol, which provides mandatory locking semantics. .PP Remote and mandatory locking semantics may vary with SMB protocol, mount options and server type. See \fBmount.cifs\fP(8) for additional information. .SH "VÉASE TAMBIÉN" \fBflock\fP(1), \fBclose\fP(2), \fBdup\fP(2), \fBexecve\fP(2), \fBfcntl\fP(2), \fBfork\fP(2), \fBopen\fP(2), \fBlockf\fP(3), \fBlslocks\fP(8) .PP \fIDocumentation/filesystems/locks.txt\fP in the Linux kernel source tree (\fIDocumentation/locks.txt\fP in older kernels) .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Gerardo Aburruzaga García , Juan Piernas , Miguel Pérez Ibars y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .