[opam-lib 1.2] Backport the "fix-wait" patch from opam-lib master.