{"action":"created","issue":{"url":"https://api.github.com/repos/etresoft/EtreCheck/issues/2","labels_url":"https://api.github.com/repos/etresoft/EtreCheck/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/etresoft/EtreCheck/issues/2/comments","events_url":"https://api.github.com/repos/etresoft/EtreCheck/issues/2/events","html_url":"https://github.com/etresoft/EtreCheck/issues/2","id":123199205,"number":2,"title":"NSTask isRunning is used","user":{"login":"jkbullard","id":127273,"avatar_url":"https://avatars.githubusercontent.com/u/127273?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbullard","html_url":"https://github.com/jkbullard","followers_url":"https://api.github.com/users/jkbullard/followers","following_url":"https://api.github.com/users/jkbullard/following{/other_user}","gists_url":"https://api.github.com/users/jkbullard/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbullard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbullard/subscriptions","organizations_url":"https://api.github.com/users/jkbullard/orgs","repos_url":"https://api.github.com/users/jkbullard/repos","events_url":"https://api.github.com/users/jkbullard/events{/privacy}","received_events_url":"https://api.github.com/users/jkbullard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-21T02:25:56Z","updated_at":"2015-12-21T17:41:58Z","closed_at":null,"body":"First, to the developers: Thank you for this program. It's great and very useful.\r\n\r\nInvestigating a problem in [Tunnelblick](https://tunnelblick.net), a GPLv2 GUI for OpenVPN, I had several of my users run EtreCheck. For some of them the program took more than an hour to run and its output contained a lot programs listed in red under the heading \"The following internal tasks failed to complete:\" I think I have found the reason.\r\n\r\nIn EtreCheck's Utilities.m, the `execute:arguments:options:error:` method uses NSTask's isRunning method. The [NSTask Class Reference document](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSTask_Class/index.html#//apple_ref/doc/uid/20000317-SW7) has a curious note about that method:\r\n\r\n           \"Available in OS X v10.10 through OS X v10.9\"\r\n\r\nThe problem with Tunnelblick was apparently caused by isRunning sometimes returning TRUE even when the task had terminated, and sometimes returning FALSE when the task was still executing. This only happened occasionally, sometimes only weeks after a system boot, usually but not always on heavily loaded systems, and in my users experience, only on OS X 10.11. I think this same problem is causing EtreCheck to believe that an internal task failed to complete.\r\n\r\nLooking at the EtreCheck code, I see another problem in `execute:arguments:options:error:` method that Tunnelblick had when doing similar operations: the pipes that the method uses are not emptied until the task has finished executing. This can cause a problem if a task has a lot of output because the buffer can fill up and stall the task (for Tunnelblick, that seemed to happen when a system was heavily loaded and/or low on memory; perhaps OS X uses smaller buffers in that situation). The solution that Tunnelblick used to deal with that was to empty the pipes as the task was running. To fix the problem my users were having, I rewrote the code to (A) use normal files instead of pipes, and (B) avoid the use of isRunning. You might want to do something similar for EtreCheck.\r\n\r\nYou can find Tunnelblick on GitHub [here](https://github.com/Tunnelblick//Tunnelblick). I have attached [the method](https://github.com/etresoft/EtreCheck/files/68022/runTool.txt) that Tunnelblick now uses to run an external program in the hope that it might help you modify EtreCheck. It does not use Grand Central Dispatch (I believe EtreCheck does) in part because it runs on OS X 10.4 which does not include it. It uses an external function to create a temporary directory for temporary files, but if you don't do operations in parallel you could probably use files with fixed paths.\r\n\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/etresoft/EtreCheck/issues/comments/166370048","html_url":"https://github.com/etresoft/EtreCheck/issues/2#issuecomment-166370048","issue_url":"https://api.github.com/repos/etresoft/EtreCheck/issues/2","id":166370048,"user":{"login":"jkbullard","id":127273,"avatar_url":"https://avatars.githubusercontent.com/u/127273?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbullard","html_url":"https://github.com/jkbullard","followers_url":"https://api.github.com/users/jkbullard/followers","following_url":"https://api.github.com/users/jkbullard/following{/other_user}","gists_url":"https://api.github.com/users/jkbullard/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbullard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbullard/subscriptions","organizations_url":"https://api.github.com/users/jkbullard/orgs","repos_url":"https://api.github.com/users/jkbullard/repos","events_url":"https://api.github.com/users/jkbullard/events{/privacy}","received_events_url":"https://api.github.com/users/jkbullard/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T17:41:58Z","updated_at":"2015-12-21T17:41:58Z","body":"Thanks, that's interesting. I've never had a problem with NSFileHandle, but then I've never had this problem before, either. I figured that because isRunning has that strange note that it was the most likely culprit.\r\n\r\nI don't need you to change EtreCheck, and my users probably don't either, so there's no rush. I mostly wanted to give you a heads-up about a potential problem.\r\n\r\nAnd thanks again for creating EtreCheck and for making it FOSS."}}