[userprog] fix race and prevent double wait