lockf(3) Library Functions Manual lockf(3) NOMBRE lockf - aplica, comprueba o elimina un bloqueo POSIX sobre un fichero abierto BIBLIOTECA Biblioteca Estandar C (libc, -lc) SINOPSIS #include int lockf(int fd, int cmd, off_t len); Requisitos de Macros de Prueba de Caracteristicas para glibc (vease feature_test_macros(7)): lockf(): _XOPEN_SOURCE >= 500 || /* glibc >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE DESCRIPCION Apply, test, or remove a POSIX lock on a section of an open file. The file is specified by fd, a file descriptor open for writing, the action by cmd, and the section consists of byte positions pos..pos+len-1 if len is positive, and pos-len..pos-1 if len is negative, where pos is the current file position, and if len is zero, the section extends from the current file position to infinity, encompassing the present and future end-of-file positions. In all cases, the section may extend past current end-of-file. On Linux, lockf() is just an interface on top of fcntl(2) locking. Many other systems implement lockf() in this way, but note that POSIX.1 leaves the relationship between lockf() and fcntl(2) locks unspecified. A portable application should probably avoid mixing calls to these interfaces. Las operaciones validas son: F_LOCK Establece un bloqueo exclusivo en la seccion especificada del fichero. Si (parte de) esta seccion ya esta bloqueada, la llamada se bloquea hasta que el bloqueo anterior sea liberado. Si esta seccion se solapa con una seccion previamente bloqueada, ambas se fusionan. Los bloqueos sobre el fichero son liberados tan pronto como el proceso que mantiene los bloqueos cierre algunos descriptores de fichero para el fichero. Un proceso hijo no hereda estos bloqueos. F_TLOCK Igual que F_LOCK pero la llamada nunca se bloquea y devuelve un error en su lugar si el fichero ya esta bloqueado. F_ULOCK Desbloquea la seccion indicada del fichero. Esto puede provocar que una seccion bloqueada se divida en dos secciones bloqueadas. F_TEST Test the lock: return 0 if the specified section is unlocked or locked by this process; return -1, set errno to EAGAIN (EACCES on some other systems), if another process holds a lock. VALOR DEVUELTO En caso de exito se devuelve cero. En caso de error se devuelve -1, y errno se configura para indicar el error. ERRORES EACCES o EAGAIN El fichero esta bloqueado y se especifico F_TLOCK o F_TEST, o se prohibe la operacion porque el fichero ha sido ubicado en memoria por otro proceso. EBADF fd is not an open file descriptor; or cmd is F_LOCK or F_TLOCK and fd is not a writable file descriptor. EDEADLK La orden fue F_LOCK y esta operacion de bloqueo causaria una situacion de interbloqueo. EINTR While waiting to acquire a lock, the call was interrupted by delivery of a signal caught by a handler; see signal(7). EINVAL Se especifico una operacion invalida en cmd. ENOLCK Demasiados bloqueos de segmento abiertos, la tabla de bloqueos esta llena. ATRIBUTOS Para obtener una explicacion de los terminos usados en esta seccion, vease attributes(7). +-----------------------------+--------------------+-------------------+ |Interfaz | Atributo | Valor | +-----------------------------+--------------------+-------------------+ |lockf() | Seguridad del hilo | Multi-hilo seguro | +-----------------------------+--------------------+-------------------+ ESTANDARES POSIX.1-2008. HISTORIAL POSIX.1-2001, SVr4. VEASE TAMBIEN fcntl(2), flock(2) locks.txt and mandatory-locking.txt in the Linux kernel source directory Documentation/filesystems (on older kernels, these files are directly under the Documentation directory, and mandatory-locking.txt is called mandatory.txt) TRADUCCION La traduccion al espanol de esta pagina del manual fue creada por Miguel Perez Ibars Esta traduccion es documentacion libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. Si encuentra algun error en la traduccion de esta pagina del manual, envie un correo electronico a . Paginas de manual de Linux 6.06 31 Octubre 2023 lockf(3)