{"action":"created","issue":{"url":"https://api.github.com/repos/chneukirchen/extrace/issues/4","repository_url":"https://api.github.com/repos/chneukirchen/extrace","labels_url":"https://api.github.com/repos/chneukirchen/extrace/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/chneukirchen/extrace/issues/4/comments","events_url":"https://api.github.com/repos/chneukirchen/extrace/issues/4/events","html_url":"https://github.com/chneukirchen/extrace/issues/4","id":360794400,"node_id":"MDU6SXNzdWUzNjA3OTQ0MDA=","number":4,"title":"pwait waits forever if PID does not exist","user":{"login":"tbetker-rs","id":37801455,"node_id":"MDQ6VXNlcjM3ODAxNDU1","avatar_url":"https://avatars1.githubusercontent.com/u/37801455?v=4","gravatar_id":"","url":"https://api.github.com/users/tbetker-rs","html_url":"https://github.com/tbetker-rs","followers_url":"https://api.github.com/users/tbetker-rs/followers","following_url":"https://api.github.com/users/tbetker-rs/following{/other_user}","gists_url":"https://api.github.com/users/tbetker-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tbetker-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbetker-rs/subscriptions","organizations_url":"https://api.github.com/users/tbetker-rs/orgs","repos_url":"https://api.github.com/users/tbetker-rs/repos","events_url":"https://api.github.com/users/tbetker-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tbetker-rs/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-17T09:51:20Z","updated_at":"2018-09-19T15:39:30Z","closed_at":"2018-09-17T11:22:48Z","author_association":"NONE","body":"If a PID does not exist, `pwait` should return immediately. Instead, it waits forever because it never receives a netlink message that the PID has exited.\r\n\r\nThis can be fixed by checking the PIDs after connecting the netlink socket, but before running the netlink listener loop. I am attaching a (tested) patch that shows what I have in mind.\r\n\r\nNote (1): I don't check for duplicate PIDs (as you do in the loop), so if a PID appears twice, you will see two messages \"process id does not exist\".\r\n\r\nNote (2): I am not sure how to handle PID 0. You accept it as valid initially, but then use pids[n] = 0 to indicate that the PID has died. Since kill(0, ...) has a special meaning, I had to check for PID 0, and I have added a message telling the user that the PID is ignored, just in case.\r\n\r\nNote (3): It might be helpful if `pwait` accepted an empty PID list, returning immediately without an error message. This would allow for things like `pwait $(pidof myprocess)`; that's just a suggestion, though.\r\n\r\n[pwait-check-pids.patch.txt](https://github.com/chneukirchen/extrace/files/2388038/pwait-check-pids.patch.txt)\r\n"},"comment":{"url":"https://api.github.com/repos/chneukirchen/extrace/issues/comments/422851356","html_url":"https://github.com/chneukirchen/extrace/issues/4#issuecomment-422851356","issue_url":"https://api.github.com/repos/chneukirchen/extrace/issues/4","id":422851356,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjg1MTM1Ng==","user":{"login":"chneukirchen","id":139,"node_id":"MDQ6VXNlcjEzOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/139?v=4","gravatar_id":"","url":"https://api.github.com/users/chneukirchen","html_url":"https://github.com/chneukirchen","followers_url":"https://api.github.com/users/chneukirchen/followers","following_url":"https://api.github.com/users/chneukirchen/following{/other_user}","gists_url":"https://api.github.com/users/chneukirchen/gists{/gist_id}","starred_url":"https://api.github.com/users/chneukirchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chneukirchen/subscriptions","organizations_url":"https://api.github.com/users/chneukirchen/orgs","repos_url":"https://api.github.com/users/chneukirchen/repos","events_url":"https://api.github.com/users/chneukirchen/events{/privacy}","received_events_url":"https://api.github.com/users/chneukirchen/received_events","type":"User","site_admin":false},"created_at":"2018-09-19T15:39:30Z","updated_at":"2018-09-19T15:39:30Z","author_association":"OWNER","body":"Good point, moved it."}}
{"actor":{"display_login":"chneukirchen"}}