{"action":"created","issue":{"url":"https://api.github.com/repos/nightlyone/lockfile/issues/10","repository_url":"https://api.github.com/repos/nightlyone/lockfile","labels_url":"https://api.github.com/repos/nightlyone/lockfile/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/nightlyone/lockfile/issues/10/comments","events_url":"https://api.github.com/repos/nightlyone/lockfile/issues/10/events","html_url":"https://github.com/nightlyone/lockfile/issues/10","id":152980878,"number":10,"title":"Failer on windows when pid is from dead process","user":{"login":"xiegeo","id":3104386,"avatar_url":"https://avatars.githubusercontent.com/u/3104386?v=3","gravatar_id":"","url":"https://api.github.com/users/xiegeo","html_url":"https://github.com/xiegeo","followers_url":"https://api.github.com/users/xiegeo/followers","following_url":"https://api.github.com/users/xiegeo/following{/other_user}","gists_url":"https://api.github.com/users/xiegeo/gists{/gist_id}","starred_url":"https://api.github.com/users/xiegeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiegeo/subscriptions","organizations_url":"https://api.github.com/users/xiegeo/orgs","repos_url":"https://api.github.com/users/xiegeo/repos","events_url":"https://api.github.com/users/xiegeo/events{/privacy}","received_events_url":"https://api.github.com/users/xiegeo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-04T10:35:24Z","updated_at":"2016-05-04T12:24:13Z","closed_at":null,"body":"os: windows (tested on win10)\r\n\r\nReproduce:\r\n1. Create lock file.\r\n2. Exit process without cleaning up lock file. (as happens when you crash)\r\n3. TryLock from new process.\r\n\r\nThis will produce `OpenProcess: The parameter is incorrect.` error, when it should succeed.\r\n\r\nCause:\r\n```\r\nfunc (l Lockfile) GetOwner() (*os.Process, error) {\r\n\t...\r\n\t\tp, err := os.FindProcess(pid)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t...\r\n}\r\n```\r\n\r\nhttps://golang.org/pkg/os/#FindProcess\r\n\r\n> On Unix systems, FindProcess always succeeds and returns a Process for the given pid, regardless of whether the process exists.  \r\n\r\nBut it's not documented for windows, and appears to return the error when process does not exit.\r\n\r\nFix:\r\n\r\nWe can assume that if the process exists, then FindProcess always succeeds in any operating system. There for, if FindProcess process returns an error, the process does not exist. So instead of returning the err, return ErrInvalidPid or ErrDeadOwner sould work here."},"comment":{"url":"https://api.github.com/repos/nightlyone/lockfile/issues/comments/216843973","html_url":"https://github.com/nightlyone/lockfile/issues/10#issuecomment-216843973","issue_url":"https://api.github.com/repos/nightlyone/lockfile/issues/10","id":216843973,"user":{"login":"nightlyone","id":1767118,"avatar_url":"https://avatars.githubusercontent.com/u/1767118?v=3","gravatar_id":"","url":"https://api.github.com/users/nightlyone","html_url":"https://github.com/nightlyone","followers_url":"https://api.github.com/users/nightlyone/followers","following_url":"https://api.github.com/users/nightlyone/following{/other_user}","gists_url":"https://api.github.com/users/nightlyone/gists{/gist_id}","starred_url":"https://api.github.com/users/nightlyone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightlyone/subscriptions","organizations_url":"https://api.github.com/users/nightlyone/orgs","repos_url":"https://api.github.com/users/nightlyone/repos","events_url":"https://api.github.com/users/nightlyone/events{/privacy}","received_events_url":"https://api.github.com/users/nightlyone/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T12:24:13Z","updated_at":"2016-05-04T12:24:13Z","body":"@xiegeo Would you be interested in creating a pull-request to fix this? I am not a Windows expert and thus have trouble fixing and reproducing this."}}