A big thanks to jhb@ for pushing much of the housekeeping around semaphores into the file descriptor layer, btw; without his major help, the fix for the logic wouldn't have been a one line diff.