{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/56270431","id":56270431,"diff_hunk":"@@ -8,17 +8,38 @@ import (\n \t\"github.com/docker/engine-api/types\"\n )\n \n-func (cli *DockerCli) holdHijackedConnection(tty bool, inputStream io.ReadCloser, outputStream, errorStream io.Writer, resp types.HijackedResponse) error {\n-\tvar err error\n+func (cli *DockerCli) holdHijackedConnection(tty bool, inputStream io.ReadCloser, outputStream, errorStream io.Writer, resp types.HijackedResponse, exitCh chan struct{}) error {\n+\tvar (\n+\t\terr      error\n+\t\trestored bool\n+\t)\n+\tif inputStream != nil && tty {\n+\t\tif err := cli.setRawTerminal(); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tdefer func() {\n+\t\t\tif !restored {","path":"api/client/hijack.go","position":16,"original_position":16,"commit_id":"f859c4d11a45f6fab546727a15f1297078b5809b","original_commit_id":"f859c4d11a45f6fab546727a15f1297078b5809b","user":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"body":"@LK4D4  use sync.Once is a good idea :+1: ","created_at":"2016-03-16T01:35:41Z","updated_at":"2016-03-16T01:35:41Z","html_url":"https://github.com/docker/docker/pull/20589#discussion_r56270431","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/20589","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/56270431"},"html":{"href":"https://github.com/docker/docker/pull/20589#discussion_r56270431"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/20589"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/20589","id":60277980,"html_url":"https://github.com/docker/docker/pull/20589","diff_url":"https://github.com/docker/docker/pull/20589.diff","patch_url":"https://github.com/docker/docker/pull/20589.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/20589","number":20589,"state":"open","locked":false,"title":"cli: move setRawTerminal and restoreTerminal to holdHijackedConnection","user":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"body":"In this way, we can restore the Terminal as soon as possible once the hijacked\r\nconnection end. This not only fix weird output if cli enable -D, but also\r\nremove duplicate code.\r\n\r\nSigned-off-by: Lei Jitang <leijitang@huawei.com>\r\n\r\nfollow #20587 \r\n@cpuguy83 @LK4D4 @icecrime @estesp @MHBauer \r\nI'll remove @MHBauer 's commit is merged.","created_at":"2016-02-23T02:31:48Z","updated_at":"2016-03-16T01:35:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57f7c961c1850e8e08e36fe1cf2bb7484132d8ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/20589/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/20589/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/20589/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/f859c4d11a45f6fab546727a15f1297078b5809b","head":{"label":"coolljt0725:fix_restore_terminal","ref":"fix_restore_terminal","sha":"f859c4d11a45f6fab546727a15f1297078b5809b","user":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"repo":{"id":24972258,"name":"docker","full_name":"coolljt0725/docker","owner":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/coolljt0725/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/coolljt0725/docker","forks_url":"https://api.github.com/repos/coolljt0725/docker/forks","keys_url":"https://api.github.com/repos/coolljt0725/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coolljt0725/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coolljt0725/docker/teams","hooks_url":"https://api.github.com/repos/coolljt0725/docker/hooks","issue_events_url":"https://api.github.com/repos/coolljt0725/docker/issues/events{/number}","events_url":"https://api.github.com/repos/coolljt0725/docker/events","assignees_url":"https://api.github.com/repos/coolljt0725/docker/assignees{/user}","branches_url":"https://api.github.com/repos/coolljt0725/docker/branches{/branch}","tags_url":"https://api.github.com/repos/coolljt0725/docker/tags","blobs_url":"https://api.github.com/repos/coolljt0725/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coolljt0725/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coolljt0725/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/coolljt0725/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coolljt0725/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/coolljt0725/docker/languages","stargazers_url":"https://api.github.com/repos/coolljt0725/docker/stargazers","contributors_url":"https://api.github.com/repos/coolljt0725/docker/contributors","subscribers_url":"https://api.github.com/repos/coolljt0725/docker/subscribers","subscription_url":"https://api.github.com/repos/coolljt0725/docker/subscription","commits_url":"https://api.github.com/repos/coolljt0725/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/coolljt0725/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/coolljt0725/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/coolljt0725/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/coolljt0725/docker/contents/{+path}","compare_url":"https://api.github.com/repos/coolljt0725/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coolljt0725/docker/merges","archive_url":"https://api.github.com/repos/coolljt0725/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coolljt0725/docker/downloads","issues_url":"https://api.github.com/repos/coolljt0725/docker/issues{/number}","pulls_url":"https://api.github.com/repos/coolljt0725/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/coolljt0725/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/coolljt0725/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coolljt0725/docker/labels{/name}","releases_url":"https://api.github.com/repos/coolljt0725/docker/releases{/id}","deployments_url":"https://api.github.com/repos/coolljt0725/docker/deployments","created_at":"2014-10-09T03:32:31Z","updated_at":"2015-03-28T01:04:57Z","pushed_at":"2016-03-02T01:28:05Z","git_url":"git://github.com/coolljt0725/docker.git","ssh_url":"git@github.com:coolljt0725/docker.git","clone_url":"https://github.com/coolljt0725/docker.git","svn_url":"https://github.com/coolljt0725/docker","homepage":"http://www.docker.com","size":82224,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"7f223b72dd826c1f925b01d159a97c28983ed07b","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-03-16T00:59:28Z","pushed_at":"2016-03-16T01:34:07Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":138101,"stargazers_count":29485,"watchers_count":29485,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8276,"mirror_url":null,"open_issues_count":1403,"forks":8276,"open_issues":1403,"watchers":29485,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/20589"},"html":{"href":"https://github.com/docker/docker/pull/20589"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/20589"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/20589/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/20589/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/20589/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/f859c4d11a45f6fab546727a15f1297078b5809b"}}}}