summaryrefslogtreecommitdiffstats
path: root/archbuild.in
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2017-03-25 17:34:39 +0100
committerJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2017-04-05 22:03:00 +0200
commitd33344081006d3f653651f0895b143c305e9e7c7 (patch)
tree04807f33567e3c25253af7ead5813e840655fbc9 /archbuild.in
parent997bc1dc0db12ee5791bfb74f07c91ce10ed7cfd (diff)
downloaddevtools-d33344081006d3f653651f0895b143c305e9e7c7.tar.gz
devtools-d33344081006d3f653651f0895b143c305e9e7c7.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 'archbuild.in')
0 files changed, 0 insertions, 0 deletions