semaphore: Support cancellation in wait functions of semaphore fallback