summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2012-11-25 20:05:09 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2017-02-06 03:14:35 -0500
commita181e77c492f7cbd454634c6d65151d6bb13ae25 (patch)
tree25e7852c54887de4a97265683ee4de7c044d3b7f /Makefile
parent09bc36a930319d1287c41b78b24acfb36b0a8715 (diff)
downloaddevtools32-a181e77c492f7cbd454634c6d65151d6bb13ae25.tar.xz
lib/common.sh: lock, slock: Allow locks to be inherited.
Allow for locks to be inherited. Inheriting the lock is something that mkarchroot could do previously, but has since lost the ability to do. This allows for the programs to be more compos-able. Do this by instead of unconditionally opening $file on $fd, first check if $file is already open on $fd; and go ahead use it if it is. The naive way of doing this would be to `$(readlink /dev/fd/$fd)` and compare that to `$file`. However, if `$file` is itself a symlink; or there is a symlink somewhere in the path to `$file`, then this could easily fail. Instead, check `[[ "/dev/fd/$fd" -ef "$file" ]]`. Even though the Bash documentation (`help test`) says that `-ef` checks for if the two files are hard links to eachother, because it uses stat(3) (which resolves symlinks) to do this check, it also works with the /dev/fd/ soft links.
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions