Não, flock
, que é um wrapper na chamada do sistema flock()
, bloqueia arquivos, não descritores de arquivos.
O manual do OpenBSD para flock()
diz (minha ênfase):
flock()
applies or removes an advisory lock on the file associated with the file descriptorfd
.[...]
Locks are on files, not file descriptors. That is, file descriptors duplicated through
dup(2)
orfork(2)
do not result in multiple instances of a lock, but rather multiple references to a single lock. If a process holding a lock on a file forks and the child explicitly unlocks the file, the parent will lose its lock.
flock()
é uma chamada do sistema; o kernel controla os bloqueios.