{"action":"created","issue":{"url":"https://api.github.com/repos/SeattleTestbed/repy_v2/issues/98","labels_url":"https://api.github.com/repos/SeattleTestbed/repy_v2/issues/98/labels{/name}","comments_url":"https://api.github.com/repos/SeattleTestbed/repy_v2/issues/98/comments","events_url":"https://api.github.com/repos/SeattleTestbed/repy_v2/issues/98/events","html_url":"https://github.com/SeattleTestbed/repy_v2/issues/98","id":84006920,"number":98,"title":"Linux `GETTID` syscall problem on OpenWrt","user":{"login":"aaaaalbert","id":3806695,"avatar_url":"https://avatars.githubusercontent.com/u/3806695?v=3","gravatar_id":"","url":"https://api.github.com/users/aaaaalbert","html_url":"https://github.com/aaaaalbert","followers_url":"https://api.github.com/users/aaaaalbert/followers","following_url":"https://api.github.com/users/aaaaalbert/following{/other_user}","gists_url":"https://api.github.com/users/aaaaalbert/gists{/gist_id}","starred_url":"https://api.github.com/users/aaaaalbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaaaalbert/subscriptions","organizations_url":"https://api.github.com/users/aaaaalbert/orgs","repos_url":"https://api.github.com/users/aaaaalbert/repos","events_url":"https://api.github.com/users/aaaaalbert/events{/privacy}","received_events_url":"https://api.github.com/users/aaaaalbert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-02T12:45:54Z","updated_at":"2015-12-01T16:22:06Z","closed_at":null,"body":"I saw this exception running RepyV2 code in a vessel on Guilherme Martin's [WNDR3800 OpenWrt router](http://wiki.openwrt.org/toh/netgear/wndr3800). My program calls `getresources()`. Then `linux_api.py` tries to read the current task's CPU consumption, but the `_get_current_thread_id()` call returns `-1`. This leads `get_current_thread_cpu_time()` into a non-existing dir, crashing the Repy program.\r\n\r\n```\r\n========================================\r\nRunning program: easy-loop.r2py\r\nArguments: []\r\n========================================\r\n---\r\nUncaught exception!\r\n---\r\nFollowing is a full traceback, and a user traceback.\r\nThe user traceback excludes non-user modules. The most recent call is displayed last.\r\n\r\nFull debugging traceback:\r\n  \"repyV2/repy.py\", line 177, in execute_namespace_until_completion\r\n  \"/mnt/seattle/seattle_repy/repyV2/virtual_namespace.py\", line 117, in evaluate\r\n  \"/mnt/seattle/seattle_repy/repyV2/safe.py\", line 588, in safe_run\r\n  \"easy-loop.r2py\", line 3, in <module>\r\n  \"/mnt/seattle/seattle_repy/repyV2/nonportable.py\", line 319, in get_resources\r\n  \"/mnt/seattle/seattle_repy/repyV2/linux_api.py\", line 227, in get_current_thread_cpu_time\r\n  \"/mnt/seattle/seattle_repy/repyV2/linux_api.py\", line 100, in _process_stat_file\r\n\r\nUser traceback:\r\n  \"easy-loop.r2py\", line 3, in <module>\r\n  \"/mnt/seattle/seattle_repy/repyV2/linux_api.py\", line 227, in get_current_thread_cpu_time\r\n  \"/mnt/seattle/seattle_repy/repyV2/linux_api.py\", line 100, in _process_stat_file\r\n\r\nException (with type 'exceptions.IOError'): [Errno 2] No such file or directory: '/proc/5652/task/-1/stat'\r\n```"},"comment":{"url":"https://api.github.com/repos/SeattleTestbed/repy_v2/issues/comments/161020063","html_url":"https://github.com/SeattleTestbed/repy_v2/issues/98#issuecomment-161020063","issue_url":"https://api.github.com/repos/SeattleTestbed/repy_v2/issues/98","id":161020063,"user":{"login":"XuefengHuang","id":6812869,"avatar_url":"https://avatars.githubusercontent.com/u/6812869?v=3","gravatar_id":"","url":"https://api.github.com/users/XuefengHuang","html_url":"https://github.com/XuefengHuang","followers_url":"https://api.github.com/users/XuefengHuang/followers","following_url":"https://api.github.com/users/XuefengHuang/following{/other_user}","gists_url":"https://api.github.com/users/XuefengHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/XuefengHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuefengHuang/subscriptions","organizations_url":"https://api.github.com/users/XuefengHuang/orgs","repos_url":"https://api.github.com/users/XuefengHuang/repos","events_url":"https://api.github.com/users/XuefengHuang/events{/privacy}","received_events_url":"https://api.github.com/users/XuefengHuang/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T16:22:05Z","updated_at":"2015-12-01T16:22:05Z","body":"On OpenWrt, the pid is the same as thread id. If I change [this line](https://github.com/SeattleTestbed/repy_v2/blob/master/linux_api.py#L224) to `file = \"/proc/\"+str(pid)+\"/task/\"+str(pid)+\"/stat\"`, it will work! But I think it will not work if one program have multiple threads. "}}