flock -x ./lock dd 结束前 flock -x ./lock ls 会一直等待

也有对应的api flock int flock(int fd, int operation);