{"action":"created","issue":{"url":"https://api.github.com/repos/appium/appium/issues/7370","repository_url":"https://api.github.com/repos/appium/appium","labels_url":"https://api.github.com/repos/appium/appium/issues/7370/labels{/name}","comments_url":"https://api.github.com/repos/appium/appium/issues/7370/comments","events_url":"https://api.github.com/repos/appium/appium/issues/7370/events","html_url":"https://github.com/appium/appium/issues/7370","id":193692915,"number":7370,"title":"Instruments doesn't always shut down on driver quit, leaks processes over time","user":{"login":"rkavalap","id":80310,"avatar_url":"https://avatars.githubusercontent.com/u/80310?v=3","gravatar_id":"","url":"https://api.github.com/users/rkavalap","html_url":"https://github.com/rkavalap","followers_url":"https://api.github.com/users/rkavalap/followers","following_url":"https://api.github.com/users/rkavalap/following{/other_user}","gists_url":"https://api.github.com/users/rkavalap/gists{/gist_id}","starred_url":"https://api.github.com/users/rkavalap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkavalap/subscriptions","organizations_url":"https://api.github.com/users/rkavalap/orgs","repos_url":"https://api.github.com/users/rkavalap/repos","events_url":"https://api.github.com/users/rkavalap/events{/privacy}","received_events_url":"https://api.github.com/users/rkavalap/received_events","type":"User","site_admin":false},"labels":[{"id":143265062,"url":"https://api.github.com/repos/appium/appium/labels/NeedsTriage","name":"NeedsTriage","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-06T06:23:48Z","updated_at":"2016-12-06T15:45:24Z","closed_at":null,"body":"@vicwomg commented on [Mon May 23 2016](https://github.com/appium/appium-instruments/issues/72)\n\nFrom the discussion here: \nhttps://discuss.appium.io/t/cannot-delete-session-driver-quit/9823\n\nInstruments intermittently doesn't shut down and this log entry is shown\n\n> [iOS] Instruments didn't shut down. Error: Instruments did not terminate after 5 seconds!\n> [debug] [iOSLog] Stopping iOS log capture\n> [debug] [iOS] Reset not set, not ending sim\n\nOver time on long test suites, old instruments processes can start to stack up and lead to hangs on simulator launch.\n\nLooks like the old instruments.js in appium 1.4.X was much more draconian about killing instruments, issuing SIGKILL\n\nappium/node_modules/appium-instruments/lib/instruments.js, line 92\n\n> Instruments.killAll = function () {\n> logger.debug(\"Killall instruments\");\n> exec('pkill -9 instruments');\n> };\n\nWhereas the new one has a more polite approach:\n\nappium/node_modules/appium-instruments/lib/instruments.js, line 755\n\n> _logger2['default'].debug('Sending sigterm to instruments');\n> this.proc.kill('SIGTERM');\n\nSure enough when I override driver.quit() and add a hard-coded \"pkill -9 instruments\" my long test runs no longer fail to launch nor leak instruments processes.\n\nI also confirmed that changing the above to this.proc.kill('SIGKILL'); fixes the issue\n\nAnyone see a reason not to just issue a SIGKILL? Not sure how instruments gets into this state, but it does happen with 100% reproducibility for one of my tests.\n\n\n---\n\n@midopa commented on [Wed Jun 08 2016](https://github.com/appium/appium-instruments/issues/72#issuecomment-224698167)\n\nSeeing this behavior as well. After leaving my automation running I can end up with 10-50 orphaned instruments processes.\n\n\n---\n\n@midopa commented on [Wed Jun 08 2016](https://github.com/appium/appium-instruments/issues/72#issuecomment-224752675)\n\nLooking at the code briefly, it seems the only hinderance would be SIGKILL doesn't trigger listeners/callbacks that less obtrusive signals do. The question is how important is `this.onShutdownDeferred.resolve();` at https://github.com/appium/appium-instruments/blob/master/lib/instruments.js#L364 ?\n\n\n---\n\n@igalep commented on [Mon Jun 20 2016](https://github.com/appium/appium-instruments/issues/72#issuecomment-227112214)\n\nany update on this one ?\nin appium ver 1.5.3 the problem still exists\n\n\n---\n\n@imurchie commented on [Mon Jun 20 2016](https://github.com/appium/appium-instruments/issues/72#issuecomment-227197726)\n\nIf `appium-instruments@3.8.3` does not fix it, then I'm not sure what to do. It implements what @midopa suggested above.\n\n\n---\n\n@igalep commented on [Thu Jun 23 2016](https://github.com/appium/appium-instruments/issues/72#issuecomment-228048178)\n\n@imurchie if I execute **pkill -9 instruments** by using terminal , I do able to terminate running instruments , but trough the code it doesn't work ...\n\nmaybe permission issues ?\n\n\n"},"comment":{"url":"https://api.github.com/repos/appium/appium/issues/comments/265184205","html_url":"https://github.com/appium/appium/issues/7370#issuecomment-265184205","issue_url":"https://api.github.com/repos/appium/appium/issues/7370","id":265184205,"user":{"login":"igalep","id":3533224,"avatar_url":"https://avatars.githubusercontent.com/u/3533224?v=3","gravatar_id":"","url":"https://api.github.com/users/igalep","html_url":"https://github.com/igalep","followers_url":"https://api.github.com/users/igalep/followers","following_url":"https://api.github.com/users/igalep/following{/other_user}","gists_url":"https://api.github.com/users/igalep/gists{/gist_id}","starred_url":"https://api.github.com/users/igalep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igalep/subscriptions","organizations_url":"https://api.github.com/users/igalep/orgs","repos_url":"https://api.github.com/users/igalep/repos","events_url":"https://api.github.com/users/igalep/events{/privacy}","received_events_url":"https://api.github.com/users/igalep/received_events","type":"User","site_admin":false},"created_at":"2016-12-06T15:45:24Z","updated_at":"2016-12-06T15:45:24Z","body":"Any chance to solve it for appium 1.6.1 ?\r\n\r\nThanks"}}
{"actor":{"display_login":"igalep"}}