do_wait: fix sys_waitid()-specific behaviour