GitHub PullRequestReviewCommentEvent at 2014-07-20 21:58:34
Repository: lpi
Actor: bernardoamc
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/rmascarenhas/lpi/pulls/comments/15152236","id":15152236,"diff_hunk":"@@ -0,0 +1,142 @@\n+/* rt_vs_std_order.c - shows the order in which realtime signals are delivered\n+ *                     when compared to standard signals.\n+ *\n+ * Realtime signals offer more control and predictability when it comes to signal\n+ * delivery order: they are delivered in order of priority (defined by the signal\n+ * number), and in the order they were received, for signals with the same number.\n+ *\n+ * However, SUSv3 leaves unspecified the order in which signals are delivered to\n+ * a process when both realtime signals and standard signals are pending. This\n+ * program can be used to identify how the underlying platform handles this scenario.\n+ *\n+ * It does that by changing the disposition and blocking every signal.\n+ * Then, it sleepts for a given number of seconds, waiting for signals to be sent.\n+ * The user should send standard and realtime signals during this period. When\n+ * the process wakes up, the handlers are run (printing information about the\n+ * handled signal) and the process finishes.\n+ *\n+ * Usage\n+ *\n+ *    $ ./rt_vs_std_order <sleep-time>\n+ *    sleep-time - number of seconds the process should sleep.\n+ *\n+ * Running this program we learn that Linux first delivers standard signals, and\n+ * then procedes and delivers realtime signals.\n+ *\n+ * Author: Renato Mascarenhas Costa\n+ */\n+\n+#define _GNU_SOURCE\n+\n+#include <limits.h>\n+\n+#ifndef LONG_MIN\n+#  include <linux/limits.h>\n+#endif\n+\n+#include <unistd.h>\n+#include <signal.h>\n+#include <sys/types.h>\n+#include <errno.h>\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+\n+static void handler(int signal, siginfo_t *sinfo, void *ucontext);\n+\n+static void helpAndLeave(const char *progname, int status);\n+static void pexit(const char *fCall);\n+\n+int\n+main(int argc, char *argv[]) {\n+#define Fatal(...) {\\\n+  fprintf(stderr, __VA_ARGS__); \\\n+  exit(EXIT_FAILURE); \\\n+}\n+\n+  if (argc != 2) {\n+    helpAndLeave(argv[0], EXIT_FAILURE);\n+  }\n+\n+  int s;\n+  char *endptr;\n+  long sleeptime;\n+\n+  struct sigaction act;\n+  sigset_t block_mask, previous_mask;\n+\n+  sleeptime = strtol(argv[1], &endptr, 10);\n+  if (sleeptime == LONG_MIN || sleeptime == LONG_MAX || endptr == argv[1]) {\n+    Fatal(\"invalid sleep time: %s\\n\", argv[1]);\n+  }\n+\n+  /* change disposition of every signal */\n+  act.sa_sigaction = handler;\n+  act.sa_flags = SA_RESTART | SA_SIGINFO;\n+  sigfillset(&act.sa_mask);\n+\n+  for (s = 1; s < NSIG; ++s) {\n+    if (s != SIGSTOP && s != SIGKILL) {\n+      errno = 0;\n+\n+      if (sigaction(s, &act, NULL) == -1) {\n+        /* skip errors related to reserved realtime signals */\n+        if (errno != EINVAL) {\n+          pexit(\"sigaction\");\n+        }\n+      }\n+    }\n+  }\n+\n+  /* block every signal and sleep */\n+  if (sigfillset(&block_mask) == -1) {\n+    pexit(\"sigfillset\");\n+  }\n+\n+  if (sigprocmask(SIG_SETMASK, &block_mask, &previous_mask) == -1) {\n+    pexit(\"sigprocmask\");\n+  }\n+\n+  printf(\"Ready to receive signals. Sleeping for %ld seconds...\\n\", sleeptime);\n+  sleep(sleeptime);\n+\n+  /* unblock signals so that handler can be executed */\n+  printf(\"Awwwwn that was a good nap. Unblocking signals now\\n\");","path":"chap22/rt_vs_std_order.c","position":105,"original_position":105,"commit_id":"5b138641cdf19aaa9fc9d99b6303dc3d4ba633c0","original_commit_id":"5b138641cdf19aaa9fc9d99b6303dc3d4ba633c0","user":{"login":"bernardoamc","id":428984,"avatar_url":"https://avatars.githubusercontent.com/u/428984?","gravatar_id":"a7859f6e07d3b2bc6ba92acb6617ee2b","url":"https://api.github.com/users/bernardoamc","html_url":"https://github.com/bernardoamc","followers_url":"https://api.github.com/users/bernardoamc/followers","following_url":"https://api.github.com/users/bernardoamc/following{/other_user}","gists_url":"https://api.github.com/users/bernardoamc/gists{/gist_id}","starred_url":"https://api.github.com/users/bernardoamc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernardoamc/subscriptions","organizations_url":"https://api.github.com/users/bernardoamc/orgs","repos_url":"https://api.github.com/users/bernardoamc/repos","events_url":"https://api.github.com/users/bernardoamc/events{/privacy}","received_events_url":"https://api.github.com/users/bernardoamc/received_events","type":"User","site_admin":false},"body":"LOL","created_at":"2014-07-20T21:58:34Z","updated_at":"2014-07-20T21:58:34Z","html_url":"https://github.com/rmascarenhas/lpi/pull/14#discussion_r15152236","pull_request_url":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/rmascarenhas/lpi/pulls/comments/15152236"},"html":{"href":"https://github.com/rmascarenhas/lpi/pull/14#discussion_r15152236"},"pull_request":{"href":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14","id":18332495,"html_url":"https://github.com/rmascarenhas/lpi/pull/14","diff_url":"https://github.com/rmascarenhas/lpi/pull/14.diff","patch_url":"https://github.com/rmascarenhas/lpi/pull/14.patch","issue_url":"https://api.github.com/repos/rmascarenhas/lpi/issues/14","number":14,"state":"open","title":"#22 - Signals: Advanced Features","user":{"login":"rmascarenhas","id":613784,"avatar_url":"https://avatars.githubusercontent.com/u/613784?","gravatar_id":"8cb8eb3d2467ad15bb6b4d6eeac21cf3","url":"https://api.github.com/users/rmascarenhas","html_url":"https://github.com/rmascarenhas","followers_url":"https://api.github.com/users/rmascarenhas/followers","following_url":"https://api.github.com/users/rmascarenhas/following{/other_user}","gists_url":"https://api.github.com/users/rmascarenhas/gists{/gist_id}","starred_url":"https://api.github.com/users/rmascarenhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmascarenhas/subscriptions","organizations_url":"https://api.github.com/users/rmascarenhas/orgs","repos_url":"https://api.github.com/users/rmascarenhas/repos","events_url":"https://api.github.com/users/rmascarenhas/events{/privacy}","received_events_url":"https://api.github.com/users/rmascarenhas/received_events","type":"User","site_admin":false},"body":"/cc @bernardoamc","created_at":"2014-07-14T05:38:54Z","updated_at":"2014-07-20T21:58:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"801f7c08dd1fe07ea7b1950f13e15da26f897d1f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14/commits","review_comments_url":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14/comments","review_comment_url":"https://api.github.com/repos/rmascarenhas/lpi/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rmascarenhas/lpi/issues/14/comments","statuses_url":"https://api.github.com/repos/rmascarenhas/lpi/statuses/5b138641cdf19aaa9fc9d99b6303dc3d4ba633c0","head":{"label":"rmascarenhas:chap22","ref":"chap22","sha":"5b138641cdf19aaa9fc9d99b6303dc3d4ba633c0","user":{"login":"rmascarenhas","id":613784,"avatar_url":"https://avatars.githubusercontent.com/u/613784?","gravatar_id":"8cb8eb3d2467ad15bb6b4d6eeac21cf3","url":"https://api.github.com/users/rmascarenhas","html_url":"https://github.com/rmascarenhas","followers_url":"https://api.github.com/users/rmascarenhas/followers","following_url":"https://api.github.com/users/rmascarenhas/following{/other_user}","gists_url":"https://api.github.com/users/rmascarenhas/gists{/gist_id}","starred_url":"https://api.github.com/users/rmascarenhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmascarenhas/subscriptions","organizations_url":"https://api.github.com/users/rmascarenhas/orgs","repos_url":"https://api.github.com/users/rmascarenhas/repos","events_url":"https://api.github.com/users/rmascarenhas/events{/privacy}","received_events_url":"https://api.github.com/users/rmascarenhas/received_events","type":"User","site_admin":false},"repo":{"id":17816265,"name":"lpi","full_name":"rmascarenhas/lpi","owner":{"login":"rmascarenhas","id":613784,"avatar_url":"https://avatars.githubusercontent.com/u/613784?","gravatar_id":"8cb8eb3d2467ad15bb6b4d6eeac21cf3","url":"https://api.github.com/users/rmascarenhas","html_url":"https://github.com/rmascarenhas","followers_url":"https://api.github.com/users/rmascarenhas/followers","following_url":"https://api.github.com/users/rmascarenhas/following{/other_user}","gists_url":"https://api.github.com/users/rmascarenhas/gists{/gist_id}","starred_url":"https://api.github.com/users/rmascarenhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmascarenhas/subscriptions","organizations_url":"https://api.github.com/users/rmascarenhas/orgs","repos_url":"https://api.github.com/users/rmascarenhas/repos","events_url":"https://api.github.com/users/rmascarenhas/events{/privacy}","received_events_url":"https://api.github.com/users/rmascarenhas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rmascarenhas/lpi","description":"My answers for the exercises of The Linux Programming Interface book","fork":false,"url":"https://api.github.com/repos/rmascarenhas/lpi","forks_url":"https://api.github.com/repos/rmascarenhas/lpi/forks","keys_url":"https://api.github.com/repos/rmascarenhas/lpi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rmascarenhas/lpi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rmascarenhas/lpi/teams","hooks_url":"https://api.github.com/repos/rmascarenhas/lpi/hooks","issue_events_url":"https://api.github.com/repos/rmascarenhas/lpi/issues/events{/number}","events_url":"https://api.github.com/repos/rmascarenhas/lpi/events","assignees_url":"https://api.github.com/repos/rmascarenhas/lpi/assignees{/user}","branches_url":"https://api.github.com/repos/rmascarenhas/lpi/branches{/branch}","tags_url":"https://api.github.com/repos/rmascarenhas/lpi/tags","blobs_url":"https://api.github.com/repos/rmascarenhas/lpi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rmascarenhas/lpi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rmascarenhas/lpi/git/refs{/sha}","trees_url":"https://api.github.com/repos/rmascarenhas/lpi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rmascarenhas/lpi/statuses/{sha}","languages_url":"https://api.github.com/repos/rmascarenhas/lpi/languages","stargazers_url":"https://api.github.com/repos/rmascarenhas/lpi/stargazers","contributors_url":"https://api.github.com/repos/rmascarenhas/lpi/contributors","subscribers_url":"https://api.github.com/repos/rmascarenhas/lpi/subscribers","subscription_url":"https://api.github.com/repos/rmascarenhas/lpi/subscription","commits_url":"https://api.github.com/repos/rmascarenhas/lpi/commits{/sha}","git_commits_url":"https://api.github.com/repos/rmascarenhas/lpi/git/commits{/sha}","comments_url":"https://api.github.com/repos/rmascarenhas/lpi/comments{/number}","issue_comment_url":"https://api.github.com/repos/rmascarenhas/lpi/issues/comments/{number}","contents_url":"https://api.github.com/repos/rmascarenhas/lpi/contents/{+path}","compare_url":"https://api.github.com/repos/rmascarenhas/lpi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rmascarenhas/lpi/merges","archive_url":"https://api.github.com/repos/rmascarenhas/lpi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rmascarenhas/lpi/downloads","issues_url":"https://api.github.com/repos/rmascarenhas/lpi/issues{/number}","pulls_url":"https://api.github.com/repos/rmascarenhas/lpi/pulls{/number}","milestones_url":"https://api.github.com/repos/rmascarenhas/lpi/milestones{/number}","notifications_url":"https://api.github.com/repos/rmascarenhas/lpi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rmascarenhas/lpi/labels{/name}","releases_url":"https://api.github.com/repos/rmascarenhas/lpi/releases{/id}","created_at":"2014-03-17T03:35:41Z","updated_at":"2014-06-25T15:49:32Z","pushed_at":"2014-07-14T05:35:50Z","git_url":"git://github.com/rmascarenhas/lpi.git","ssh_url":"git@github.com:rmascarenhas/lpi.git","clone_url":"https://github.com/rmascarenhas/lpi.git","svn_url":"https://github.com/rmascarenhas/lpi","homepage":"","size":916,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"rmascarenhas:master","ref":"master","sha":"2a82aa717186c9608ab271ebc1719c6b67ec3a5c","user":{"login":"rmascarenhas","id":613784,"avatar_url":"https://avatars.githubusercontent.com/u/613784?","gravatar_id":"8cb8eb3d2467ad15bb6b4d6eeac21cf3","url":"https://api.github.com/users/rmascarenhas","html_url":"https://github.com/rmascarenhas","followers_url":"https://api.github.com/users/rmascarenhas/followers","following_url":"https://api.github.com/users/rmascarenhas/following{/other_user}","gists_url":"https://api.github.com/users/rmascarenhas/gists{/gist_id}","starred_url":"https://api.github.com/users/rmascarenhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmascarenhas/subscriptions","organizations_url":"https://api.github.com/users/rmascarenhas/orgs","repos_url":"https://api.github.com/users/rmascarenhas/repos","events_url":"https://api.github.com/users/rmascarenhas/events{/privacy}","received_events_url":"https://api.github.com/users/rmascarenhas/received_events","type":"User","site_admin":false},"repo":{"id":17816265,"name":"lpi","full_name":"rmascarenhas/lpi","owner":{"login":"rmascarenhas","id":613784,"avatar_url":"https://avatars.githubusercontent.com/u/613784?","gravatar_id":"8cb8eb3d2467ad15bb6b4d6eeac21cf3","url":"https://api.github.com/users/rmascarenhas","html_url":"https://github.com/rmascarenhas","followers_url":"https://api.github.com/users/rmascarenhas/followers","following_url":"https://api.github.com/users/rmascarenhas/following{/other_user}","gists_url":"https://api.github.com/users/rmascarenhas/gists{/gist_id}","starred_url":"https://api.github.com/users/rmascarenhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmascarenhas/subscriptions","organizations_url":"https://api.github.com/users/rmascarenhas/orgs","repos_url":"https://api.github.com/users/rmascarenhas/repos","events_url":"https://api.github.com/users/rmascarenhas/events{/privacy}","received_events_url":"https://api.github.com/users/rmascarenhas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rmascarenhas/lpi","description":"My answers for the exercises of The Linux Programming Interface book","fork":false,"url":"https://api.github.com/repos/rmascarenhas/lpi","forks_url":"https://api.github.com/repos/rmascarenhas/lpi/forks","keys_url":"https://api.github.com/repos/rmascarenhas/lpi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rmascarenhas/lpi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rmascarenhas/lpi/teams","hooks_url":"https://api.github.com/repos/rmascarenhas/lpi/hooks","issue_events_url":"https://api.github.com/repos/rmascarenhas/lpi/issues/events{/number}","events_url":"https://api.github.com/repos/rmascarenhas/lpi/events","assignees_url":"https://api.github.com/repos/rmascarenhas/lpi/assignees{/user}","branches_url":"https://api.github.com/repos/rmascarenhas/lpi/branches{/branch}","tags_url":"https://api.github.com/repos/rmascarenhas/lpi/tags","blobs_url":"https://api.github.com/repos/rmascarenhas/lpi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rmascarenhas/lpi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rmascarenhas/lpi/git/refs{/sha}","trees_url":"https://api.github.com/repos/rmascarenhas/lpi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rmascarenhas/lpi/statuses/{sha}","languages_url":"https://api.github.com/repos/rmascarenhas/lpi/languages","stargazers_url":"https://api.github.com/repos/rmascarenhas/lpi/stargazers","contributors_url":"https://api.github.com/repos/rmascarenhas/lpi/contributors","subscribers_url":"https://api.github.com/repos/rmascarenhas/lpi/subscribers","subscription_url":"https://api.github.com/repos/rmascarenhas/lpi/subscription","commits_url":"https://api.github.com/repos/rmascarenhas/lpi/commits{/sha}","git_commits_url":"https://api.github.com/repos/rmascarenhas/lpi/git/commits{/sha}","comments_url":"https://api.github.com/repos/rmascarenhas/lpi/comments{/number}","issue_comment_url":"https://api.github.com/repos/rmascarenhas/lpi/issues/comments/{number}","contents_url":"https://api.github.com/repos/rmascarenhas/lpi/contents/{+path}","compare_url":"https://api.github.com/repos/rmascarenhas/lpi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rmascarenhas/lpi/merges","archive_url":"https://api.github.com/repos/rmascarenhas/lpi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rmascarenhas/lpi/downloads","issues_url":"https://api.github.com/repos/rmascarenhas/lpi/issues{/number}","pulls_url":"https://api.github.com/repos/rmascarenhas/lpi/pulls{/number}","milestones_url":"https://api.github.com/repos/rmascarenhas/lpi/milestones{/number}","notifications_url":"https://api.github.com/repos/rmascarenhas/lpi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rmascarenhas/lpi/labels{/name}","releases_url":"https://api.github.com/repos/rmascarenhas/lpi/releases{/id}","created_at":"2014-03-17T03:35:41Z","updated_at":"2014-06-25T15:49:32Z","pushed_at":"2014-07-14T05:35:50Z","git_url":"git://github.com/rmascarenhas/lpi.git","ssh_url":"git@github.com:rmascarenhas/lpi.git","clone_url":"https://github.com/rmascarenhas/lpi.git","svn_url":"https://github.com/rmascarenhas/lpi","homepage":"","size":916,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14"},"html":{"href":"https://github.com/rmascarenhas/lpi/pull/14"},"issue":{"href":"https://api.github.com/repos/rmascarenhas/lpi/issues/14"},"comments":{"href":"https://api.github.com/repos/rmascarenhas/lpi/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/rmascarenhas/lpi/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rmascarenhas/lpi/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/rmascarenhas/lpi/statuses/5b138641cdf19aaa9fc9d99b6303dc3d4ba633c0"}}}}