updates-pacman-aurhelper needs synchronization when used with multiple bars.
Opened this issue · 3 comments
Because it uses the "checkupdates" script, the updates-pacman-aurhelper script will fail when executed in very short succession (as with e.g. 2 bars on 2 monitors).
checkupdates will fail if more than one instance of it is running:
$ checkupdates & checkupdates
-> This likely outputs something like
➜ ~ checkupdates & checkupdates
[1] 4287
==> ERROR: Cannot fetch updates
➜ ~ apparmor 3.0.0-2 -> 3.0.0-3
arandr 0.1.10-4 -> 0.1.10-5
...
Possible workarounds would probably be a lockfile or a loop that checks the exit status of checkupdates and sleeps for a short amount of time.
Yes, its a problem. A simpler hack could be a random sleep.
On the other hand its an edge case I would say. So I don't want to change the existing scripts for this.
I actually have a solution, which would look like this:
while true; do
updates_arch=$(((((checkupdates 2>/dev/null; echo $? >&3) | wc -l >&4) 3>&1) | (read xs; exit $xs)) 4>&1)
exitstatus=$?
if [ $exitstatus -eq 2 ]; then
updates_arch=0
break
fi
if [ $exitstatus -eq 0 ]; then
break
fi
done
This would work 100% of the time.
involves a bit of file descriptor magic in order to get the exitstatus of checkupdates and the output of wc at the same time.