q will attempt to acquire a lock on the sym file when it’s enumerating against it, so theoretically you should be able to have multiple processes enumerating against the same sym file in parallel.
q).z.i
27864
q):sym?
a
sym$
a
strace shows:
$ strace -p 27864
Process 27864 attached - interrupt to quit
read(0, “:sym?
a\n”, 4080) = 9
stat(“sym”, 0x7fff6e0fc5b0) = -1 ENOENT (No such file or directory)
unlink(“sym$”) = -1 ENOENT (No such file or directory)
open(“sym$”, O_RDWR|O_CREAT, 0666) = 3
write(3, “\377\1\v\0\0\0\0\0”, 8) = 8
close(3) = 0
rename(“sym$”, “sym”) = 0
stat(“sym#”, 0x7fff6e0fc560) = -1 ENOENT (No such file or directory)
open(“sym”, O_RDWR|O_CREAT, 0666) = 3
read(3, “\377\1\v\0\0\0\0\0”, 8) = 8
lseek(3, 0, SEEK_SET) = 0
fcntl(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_CUR, start=0, len=0}) = 0
lseek(3, 2, SEEK_SET) = 2
fstat(3, {st_mode=S_IFREG|0644, st_size=8, …}) = 0
https://www.gnu.org/software/libc/manual/html_node/File-Locks.html
However, if your sym file is on NFS this might not be safe: http://0pointer.de/blog/projects/locking.html