{"action":"created","comment":{"url":"https://api.github.com/repos/javeme/brpc/pulls/comments/104191715","pull_request_review_id":25014946,"id":104191715,"diff_hunk":"@@ -14,18 +14,118 @@ CHECK_MEMORY_LEAKS\n #include \"src/type/ObjectMap.h\"\n #include \"src/rpc/server/RpcServer.h\"\n \n+#ifndef WIN32\n+#include <signal.h>\n+#include <pthread.h>\n+\n+class SignalHandler\n+{\n+public:\n+\tstatic void catchSignals(int sigs[])\n+\t{\n+\t\t//signal(SIGSEGV, signalHandle);\n+\t\tfor(int i = 0; sigs[i] != 0; i++)\n+\t\t{\n+\t\t\tassert(SIG_ERR != signal(sigs[i], signalHandle));\n+\t\t}\n+\t}\n+\n+\tstatic void signalHandle(int sig)\n+\t{\n+\t\tprintf(\"Signal %d\\n\", sig);\n+\t\tUtil::dumpStack();\n+\t\texit(-1);\n+\t}\n+\n+\tstatic void ignoreSignal(int sig) throw(Exception)\n+\t{\n+\t\tstruct sigaction sa;\n+\t\tsa.sa_handler = SIG_IGN;\n+\t\tsa.sa_flags = 0;\n+\t\tif(sigemptyset(&sa.sa_mask) == -1 || sigaction(sig, &sa, 0) == -1)\n+\t\t{\n+\t\t\tthrow Exception(String::format(\n+\t\t\t\t\t\"Failed to set ignore signal %d.\", sig));\n+\t\t}\n+\n+\t\tsigset_t signal_mask;\n+\t\tsigemptyset(&signal_mask);\n+\t\tsigaddset(&signal_mask, sig);\n+\t\tif(pthread_sigmask(SIG_BLOCK, &signal_mask, NULL) != 0)\n+\t\t{\n+\t\t\tthrow Exception(String::format(\n+\t\t\t\t\t\"Failed to set pthread ignore signal %d.\", sig));\n+\t\t}\n+\t}\n+\n+\tstatic void ignoreSignals(int sigs[]) throw(Exception)\n+\t{\n+\t\tfor(int i = 0; sigs[i] != 0; i++)\n+\t\t{\n+\t\t\tignoreSignal(sigs[i]);\n+\t\t}\n+\t}\n+};\n+\n+// for linux like\n+static void initSignalHandler() throw(Exception)\n+{\n+\tint catches[] = {SIGSEGV, SIGBUS, SIGABRT, 0};","path":"brpc.cpp","position":60,"original_position":60,"commit_id":"61a29fb8e37e3a6f0c9208c0cc1ac370b486083f","original_commit_id":"9c257b972d88fe468ad448cea8a8efcb6ef64198","user":{"login":"javeme","id":9625821,"avatar_url":"https://avatars0.githubusercontent.com/u/9625821?v=3","gravatar_id":"","url":"https://api.github.com/users/javeme","html_url":"https://github.com/javeme","followers_url":"https://api.github.com/users/javeme/followers","following_url":"https://api.github.com/users/javeme/following{/other_user}","gists_url":"https://api.github.com/users/javeme/gists{/gist_id}","starred_url":"https://api.github.com/users/javeme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javeme/subscriptions","organizations_url":"https://api.github.com/users/javeme/orgs","repos_url":"https://api.github.com/users/javeme/repos","events_url":"https://api.github.com/users/javeme/events{/privacy}","received_events_url":"https://api.github.com/users/javeme/received_events","type":"User","site_admin":false},"body":"catch signal SIGSEGV, SIGBUS, SIGABRT and dump stack for debug","created_at":"2017-03-03T16:37:48Z","updated_at":"2017-03-03T16:49:33Z","html_url":"https://github.com/javeme/brpc/pull/1#discussion_r104191715","pull_request_url":"https://api.github.com/repos/javeme/brpc/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/javeme/brpc/pulls/comments/104191715"},"html":{"href":"https://github.com/javeme/brpc/pull/1#discussion_r104191715"},"pull_request":{"href":"https://api.github.com/repos/javeme/brpc/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/javeme/brpc/pulls/1","id":109008898,"html_url":"https://github.com/javeme/brpc/pull/1","diff_url":"https://github.com/javeme/brpc/pull/1.diff","patch_url":"https://github.com/javeme/brpc/pull/1.patch","issue_url":"https://api.github.com/repos/javeme/brpc/issues/1","number":1,"state":"open","locked":false,"title":"Port brpc to linux","user":{"login":"javeme","id":9625821,"avatar_url":"https://avatars0.githubusercontent.com/u/9625821?v=3","gravatar_id":"","url":"https://api.github.com/users/javeme","html_url":"https://github.com/javeme","followers_url":"https://api.github.com/users/javeme/followers","following_url":"https://api.github.com/users/javeme/following{/other_user}","gists_url":"https://api.github.com/users/javeme/gists{/gist_id}","starred_url":"https://api.github.com/users/javeme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javeme/subscriptions","organizations_url":"https://api.github.com/users/javeme/orgs","repos_url":"https://api.github.com/users/javeme/repos","events_url":"https://api.github.com/users/javeme/events{/privacy}","received_events_url":"https://api.github.com/users/javeme/received_events","type":"User","site_admin":false},"body":"port brpc to linux like OS","created_at":"2017-03-03T16:36:23Z","updated_at":"2017-03-03T16:49:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"42e692e4be890d839e35b44b02412e9263b8be01","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/javeme/brpc/pulls/1/commits","review_comments_url":"https://api.github.com/repos/javeme/brpc/pulls/1/comments","review_comment_url":"https://api.github.com/repos/javeme/brpc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/javeme/brpc/issues/1/comments","statuses_url":"https://api.github.com/repos/javeme/brpc/statuses/61a29fb8e37e3a6f0c9208c0cc1ac370b486083f","head":{"label":"javeme:port-to-linux","ref":"port-to-linux","sha":"61a29fb8e37e3a6f0c9208c0cc1ac370b486083f","user":{"login":"javeme","id":9625821,"avatar_url":"https://avatars0.githubusercontent.com/u/9625821?v=3","gravatar_id":"","url":"https://api.github.com/users/javeme","html_url":"https://github.com/javeme","followers_url":"https://api.github.com/users/javeme/followers","following_url":"https://api.github.com/users/javeme/following{/other_user}","gists_url":"https://api.github.com/users/javeme/gists{/gist_id}","starred_url":"https://api.github.com/users/javeme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javeme/subscriptions","organizations_url":"https://api.github.com/users/javeme/orgs","repos_url":"https://api.github.com/users/javeme/repos","events_url":"https://api.github.com/users/javeme/events{/privacy}","received_events_url":"https://api.github.com/users/javeme/received_events","type":"User","site_admin":false},"repo":{"id":37008670,"name":"brpc","full_name":"javeme/brpc","owner":{"login":"javeme","id":9625821,"avatar_url":"https://avatars0.githubusercontent.com/u/9625821?v=3","gravatar_id":"","url":"https://api.github.com/users/javeme","html_url":"https://github.com/javeme","followers_url":"https://api.github.com/users/javeme/followers","following_url":"https://api.github.com/users/javeme/following{/other_user}","gists_url":"https://api.github.com/users/javeme/gists{/gist_id}","starred_url":"https://api.github.com/users/javeme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javeme/subscriptions","organizations_url":"https://api.github.com/users/javeme/orgs","repos_url":"https://api.github.com/users/javeme/repos","events_url":"https://api.github.com/users/javeme/events{/privacy}","received_events_url":"https://api.github.com/users/javeme/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javeme/brpc","description":"a c++ rpc lib","fork":false,"url":"https://api.github.com/repos/javeme/brpc","forks_url":"https://api.github.com/repos/javeme/brpc/forks","keys_url":"https://api.github.com/repos/javeme/brpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javeme/brpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javeme/brpc/teams","hooks_url":"https://api.github.com/repos/javeme/brpc/hooks","issue_events_url":"https://api.github.com/repos/javeme/brpc/issues/events{/number}","events_url":"https://api.github.com/repos/javeme/brpc/events","assignees_url":"https://api.github.com/repos/javeme/brpc/assignees{/user}","branches_url":"https://api.github.com/repos/javeme/brpc/branches{/branch}","tags_url":"https://api.github.com/repos/javeme/brpc/tags","blobs_url":"https://api.github.com/repos/javeme/brpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javeme/brpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javeme/brpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/javeme/brpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javeme/brpc/statuses/{sha}","languages_url":"https://api.github.com/repos/javeme/brpc/languages","stargazers_url":"https://api.github.com/repos/javeme/brpc/stargazers","contributors_url":"https://api.github.com/repos/javeme/brpc/contributors","subscribers_url":"https://api.github.com/repos/javeme/brpc/subscribers","subscription_url":"https://api.github.com/repos/javeme/brpc/subscription","commits_url":"https://api.github.com/repos/javeme/brpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/javeme/brpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/javeme/brpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/javeme/brpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/javeme/brpc/contents/{+path}","compare_url":"https://api.github.com/repos/javeme/brpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javeme/brpc/merges","archive_url":"https://api.github.com/repos/javeme/brpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javeme/brpc/downloads","issues_url":"https://api.github.com/repos/javeme/brpc/issues{/number}","pulls_url":"https://api.github.com/repos/javeme/brpc/pulls{/number}","milestones_url":"https://api.github.com/repos/javeme/brpc/milestones{/number}","notifications_url":"https://api.github.com/repos/javeme/brpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javeme/brpc/labels{/name}","releases_url":"https://api.github.com/repos/javeme/brpc/releases{/id}","deployments_url":"https://api.github.com/repos/javeme/brpc/deployments","created_at":"2015-06-07T07:48:28Z","updated_at":"2017-02-28T17:34:11Z","pushed_at":"2017-03-03T16:36:24Z","git_url":"git://github.com/javeme/brpc.git","ssh_url":"git@github.com:javeme/brpc.git","clone_url":"https://github.com/javeme/brpc.git","svn_url":"https://github.com/javeme/brpc","homepage":null,"size":21745,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"javeme:master","ref":"master","sha":"0e623e433e11190598159b0d4f3d11650e6ec403","user":{"login":"javeme","id":9625821,"avatar_url":"https://avatars0.githubusercontent.com/u/9625821?v=3","gravatar_id":"","url":"https://api.github.com/users/javeme","html_url":"https://github.com/javeme","followers_url":"https://api.github.com/users/javeme/followers","following_url":"https://api.github.com/users/javeme/following{/other_user}","gists_url":"https://api.github.com/users/javeme/gists{/gist_id}","starred_url":"https://api.github.com/users/javeme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javeme/subscriptions","organizations_url":"https://api.github.com/users/javeme/orgs","repos_url":"https://api.github.com/users/javeme/repos","events_url":"https://api.github.com/users/javeme/events{/privacy}","received_events_url":"https://api.github.com/users/javeme/received_events","type":"User","site_admin":false},"repo":{"id":37008670,"name":"brpc","full_name":"javeme/brpc","owner":{"login":"javeme","id":9625821,"avatar_url":"https://avatars0.githubusercontent.com/u/9625821?v=3","gravatar_id":"","url":"https://api.github.com/users/javeme","html_url":"https://github.com/javeme","followers_url":"https://api.github.com/users/javeme/followers","following_url":"https://api.github.com/users/javeme/following{/other_user}","gists_url":"https://api.github.com/users/javeme/gists{/gist_id}","starred_url":"https://api.github.com/users/javeme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javeme/subscriptions","organizations_url":"https://api.github.com/users/javeme/orgs","repos_url":"https://api.github.com/users/javeme/repos","events_url":"https://api.github.com/users/javeme/events{/privacy}","received_events_url":"https://api.github.com/users/javeme/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javeme/brpc","description":"a c++ rpc lib","fork":false,"url":"https://api.github.com/repos/javeme/brpc","forks_url":"https://api.github.com/repos/javeme/brpc/forks","keys_url":"https://api.github.com/repos/javeme/brpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javeme/brpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javeme/brpc/teams","hooks_url":"https://api.github.com/repos/javeme/brpc/hooks","issue_events_url":"https://api.github.com/repos/javeme/brpc/issues/events{/number}","events_url":"https://api.github.com/repos/javeme/brpc/events","assignees_url":"https://api.github.com/repos/javeme/brpc/assignees{/user}","branches_url":"https://api.github.com/repos/javeme/brpc/branches{/branch}","tags_url":"https://api.github.com/repos/javeme/brpc/tags","blobs_url":"https://api.github.com/repos/javeme/brpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javeme/brpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javeme/brpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/javeme/brpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javeme/brpc/statuses/{sha}","languages_url":"https://api.github.com/repos/javeme/brpc/languages","stargazers_url":"https://api.github.com/repos/javeme/brpc/stargazers","contributors_url":"https://api.github.com/repos/javeme/brpc/contributors","subscribers_url":"https://api.github.com/repos/javeme/brpc/subscribers","subscription_url":"https://api.github.com/repos/javeme/brpc/subscription","commits_url":"https://api.github.com/repos/javeme/brpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/javeme/brpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/javeme/brpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/javeme/brpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/javeme/brpc/contents/{+path}","compare_url":"https://api.github.com/repos/javeme/brpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javeme/brpc/merges","archive_url":"https://api.github.com/repos/javeme/brpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javeme/brpc/downloads","issues_url":"https://api.github.com/repos/javeme/brpc/issues{/number}","pulls_url":"https://api.github.com/repos/javeme/brpc/pulls{/number}","milestones_url":"https://api.github.com/repos/javeme/brpc/milestones{/number}","notifications_url":"https://api.github.com/repos/javeme/brpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javeme/brpc/labels{/name}","releases_url":"https://api.github.com/repos/javeme/brpc/releases{/id}","deployments_url":"https://api.github.com/repos/javeme/brpc/deployments","created_at":"2015-06-07T07:48:28Z","updated_at":"2017-02-28T17:34:11Z","pushed_at":"2017-03-03T16:36:24Z","git_url":"git://github.com/javeme/brpc.git","ssh_url":"git@github.com:javeme/brpc.git","clone_url":"https://github.com/javeme/brpc.git","svn_url":"https://github.com/javeme/brpc","homepage":null,"size":21745,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/javeme/brpc/pulls/1"},"html":{"href":"https://github.com/javeme/brpc/pull/1"},"issue":{"href":"https://api.github.com/repos/javeme/brpc/issues/1"},"comments":{"href":"https://api.github.com/repos/javeme/brpc/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/javeme/brpc/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/javeme/brpc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/javeme/brpc/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/javeme/brpc/statuses/61a29fb8e37e3a6f0c9208c0cc1ac370b486083f"}}}}
{"actor":{"display_login":"javeme"}}