Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Cannot write to zsystem flock's descriptor



Hello,

# echo "test" > file
# zsystem flock -t 0 -f MY_FD "file"; echo $?
0
# echo a>&${MY_FD}
zsh: 11: bad file descriptor
# exec {MY_FD}>&-
(works, lock also works)

I've added debug logs to system.c and there is:

Read-write flags, 2 (O_RDWR) | 131072 (O_NOCTTY) = 131074
Before move fdflags 0
After move fdflags 0
After cloexec fdflags 1
lck.l_type RD:1, WR:3, is:3

So it looks good. When locking via "flock" util-linux program I can
write to the FD. What could it be? 

    if ((flock_fd = open(unmeta(args[0]), flags)) < 0) {

flags are like first line of debug message. I think it's open() that
matters.

-- 
  Sebastian Gniazdowski
  psprint3@xxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author