[PATCH v4 4/4] Detach input thread before waiting