Oh yes: If I put a sleep(1) call just before the exit call in lock-test.c, all the tests succeed, supporting the notion that it's a timing issue relating to closing the pty and having the parent read the pending data. But adding the sleep call doesn't fix the real problem, it just hides it.