{"action":"created","issue":{"url":"https://api.github.com/repos/giampaolo/psutil/issues/1370","repository_url":"https://api.github.com/repos/giampaolo/psutil","labels_url":"https://api.github.com/repos/giampaolo/psutil/issues/1370/labels{/name}","comments_url":"https://api.github.com/repos/giampaolo/psutil/issues/1370/comments","events_url":"https://api.github.com/repos/giampaolo/psutil/issues/1370/events","html_url":"https://github.com/giampaolo/psutil/issues/1370","id":386079256,"node_id":"MDU6SXNzdWUzODYwNzkyNTY=","number":1370,"title":"_psutil_windows.c psutil_proc_create_time does not return correct error code","user":{"login":"ReneGrellert","id":37444563,"node_id":"MDQ6VXNlcjM3NDQ0NTYz","avatar_url":"https://avatars1.githubusercontent.com/u/37444563?v=4","gravatar_id":"","url":"https://api.github.com/users/ReneGrellert","html_url":"https://github.com/ReneGrellert","followers_url":"https://api.github.com/users/ReneGrellert/followers","following_url":"https://api.github.com/users/ReneGrellert/following{/other_user}","gists_url":"https://api.github.com/users/ReneGrellert/gists{/gist_id}","starred_url":"https://api.github.com/users/ReneGrellert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReneGrellert/subscriptions","organizations_url":"https://api.github.com/users/ReneGrellert/orgs","repos_url":"https://api.github.com/users/ReneGrellert/repos","events_url":"https://api.github.com/users/ReneGrellert/events{/privacy}","received_events_url":"https://api.github.com/users/ReneGrellert/received_events","type":"User","site_admin":false},"labels":[{"id":101777835,"node_id":"MDU6TGFiZWwxMDE3Nzc4MzU=","url":"https://api.github.com/repos/giampaolo/psutil/labels/OpSys-Windows","name":"OpSys-Windows","color":"e99695","default":false},{"id":101777531,"node_id":"MDU6TGFiZWwxMDE3Nzc1MzE=","url":"https://api.github.com/repos/giampaolo/psutil/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-30T08:07:02Z","updated_at":"2018-11-30T18:08:35Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nwe've disvovered the following behaviour in the following code of psutil_proc_create_time:\r\n\r\n    if (! GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser)) {\r\n        CloseHandle(hProcess);\r\n        if (GetLastError() == ERROR_ACCESS_DENIED) {\r\n            // usually means the process has died so we throw a\r\n            // NoSuchProcess here\r\n            return NoSuchProcess(\"\");\r\n        }\r\n        else {\r\n            return PyErr_SetFromWindowsErr(0);\r\n        }\r\n    }\r\n\r\nWe think, that CloseHandle resets the error stored in \"GetLastError\". This leads to \"return PyErr_SetFromWindowsErr(0)\" returning the Error raised in CloseHandle instead of the one of \"GetProcessTimes\".\r\n\r\nWe got there from another error, we could not understand:\r\n\r\n    File \"psutil\\__init__.pyo\" line 1440, in process_iter\r\n    File \"psutil\\__init__.pyo\" line 569, in is_running\r\n    File \"psutil\\__init__.pyo\" line 340, in __init__\r\n    File \"psutil\\__init__.pyo\" line 367, in _init\r\n    File \"psutil\\__init__.pyo\" line 698, in wrapper\r\n    File \"psutil\\__init__.pyo\" line 846, in create_time\r\n    WindowsError: [Error 0]\r\n\r\nSometimes, there is an Error 2 instead. Maybe this comes from CloseHandle, since the handle might not \r\nbe valid any more.\r\n\r\nThis problem occures with\r\npython 2.7\r\npyutil 5.4.5\r\nOn Windows 7, 64 bit\r\n\r\nBest regards,\r\nRené"},"comment":{"url":"https://api.github.com/repos/giampaolo/psutil/issues/comments/443289614","html_url":"https://github.com/giampaolo/psutil/issues/1370#issuecomment-443289614","issue_url":"https://api.github.com/repos/giampaolo/psutil/issues/1370","id":443289614,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzI4OTYxNA==","user":{"login":"giampaolo","id":681260,"node_id":"MDQ6VXNlcjY4MTI2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/681260?v=4","gravatar_id":"","url":"https://api.github.com/users/giampaolo","html_url":"https://github.com/giampaolo","followers_url":"https://api.github.com/users/giampaolo/followers","following_url":"https://api.github.com/users/giampaolo/following{/other_user}","gists_url":"https://api.github.com/users/giampaolo/gists{/gist_id}","starred_url":"https://api.github.com/users/giampaolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giampaolo/subscriptions","organizations_url":"https://api.github.com/users/giampaolo/orgs","repos_url":"https://api.github.com/users/giampaolo/repos","events_url":"https://api.github.com/users/giampaolo/events{/privacy}","received_events_url":"https://api.github.com/users/giampaolo/received_events","type":"User","site_admin":false},"created_at":"2018-11-30T18:08:35Z","updated_at":"2018-11-30T18:08:35Z","author_association":"OWNER","body":"Also, there are other places with the same issue. "}}
{"actor":{"display_login":"giampaolo"}}