)]}'
{
  "commit": "fb1d910c178ba0c5bc32d3e5a9e82e05b7aad3cd",
  "tree": "dd889f33758a914cb538583073000bc21aeb1759",
  "parents": [
    "fca26f260c528ee51a2e451b5b200aeb528f3e09"
  ],
  "author": {
    "name": "Tejun Heo",
    "email": "tj@kernel.org",
    "time": "Tue Jun 14 11:20:17 2011 +0200"
  },
  "committer": {
    "name": "Oleg Nesterov",
    "email": "oleg@redhat.com",
    "time": "Thu Jun 16 21:41:53 2011 +0200"
  },
  "message": "ptrace: implement TRAP_NOTIFY and use it for group stop events\n\nCurrently there\u0027s no way for ptracer to find out whether group stop\nfinished other than polling with INTERRUPT - GETSIGINFO - CONT\nsequence.  This patch implements group stop notification for ptracer\nusing STOP traps.\n\nWhen group stop state of a seized tracee changes, JOBCTL_TRAP_NOTIFY\nis set, which schedules a STOP trap which is sticky - it isn\u0027t cleared\nby other traps and at least one STOP trap will happen eventually.\nSTOP trap is synchronization point for event notification and the\ntracer can determine the current group stop state by looking at the\nsignal number portion of exit code (si_status from waitid(2) or\nsi_code from PTRACE_GETSIGINFO).\n\nNotifications are generated both on start and end of group stops but,\nbecause group stop participation always happens before STOP trap, this\ndoesn\u0027t cause an extra trap while tracee is participating in group\nstop.  The symmetry will be useful later.\n\nNote that this notification works iff tracee is not trapped.\nCurrently there is no way to be notified of group stop state changes\nwhile tracee is trapped.  This will be addressed by a later patch.\n\nAn example program follows.\n\n  #define PTRACE_SEIZE\t\t0x4206\n  #define PTRACE_INTERRUPT\t0x4207\n\n  #define PTRACE_SEIZE_DEVEL\t0x80000000\n\n  static const struct timespec ts1s \u003d { .tv_sec \u003d 1 };\n\n  int main(int argc, char **argv)\n  {\n\t  pid_t tracee, tracer;\n\t  int i;\n\n\t  tracee \u003d fork();\n\t  if (!tracee)\n\t\t  while (1)\n\t\t\t  pause();\n\n\t  tracer \u003d fork();\n\t  if (!tracer) {\n\t\t  siginfo_t si;\n\n\t\t  ptrace(PTRACE_SEIZE, tracee, NULL,\n\t\t\t (void *)(unsigned long)PTRACE_SEIZE_DEVEL);\n\t\t  ptrace(PTRACE_INTERRUPT, tracee, NULL, NULL);\n\t  repeat:\n\t\t  waitid(P_PID, tracee, NULL, WSTOPPED);\n\n\t\t  ptrace(PTRACE_GETSIGINFO, tracee, NULL, \u0026si);\n\t\t  if (!si.si_code) {\n\t\t\t  printf(\"tracer: SIG %d\\n\", si.si_signo);\n\t\t\t  ptrace(PTRACE_CONT, tracee, NULL,\n\t\t\t\t (void *)(unsigned long)si.si_signo);\n\t\t\t  goto repeat;\n\t\t  }\n\t\t  printf(\"tracer: stopped\u003d%d signo\u003d%d\\n\",\n\t\t\t si.si_signo !\u003d SIGTRAP, si.si_signo);\n\t\t  ptrace(PTRACE_CONT, tracee, NULL, NULL);\n\t\t  goto repeat;\n\t  }\n\n\t  for (i \u003d 0; i \u003c 3; i++) {\n\t\t  nanosleep(\u0026ts1s, NULL);\n\t\t  printf(\"mother: SIGSTOP\\n\");\n\t\t  kill(tracee, SIGSTOP);\n\t\t  nanosleep(\u0026ts1s, NULL);\n\t\t  printf(\"mother: SIGCONT\\n\");\n\t\t  kill(tracee, SIGCONT);\n\t  }\n\t  nanosleep(\u0026ts1s, NULL);\n\n\t  kill(tracer, SIGKILL);\n\t  kill(tracee, SIGKILL);\n\t  return 0;\n  }\n\nIn the above program, tracer keeps tracee running and gets\nnotification of each group stop state changes.\n\n  # ./test-notify\n  tracer: stopped\u003d0 signo\u003d5\n  mother: SIGSTOP\n  tracer: SIG 19\n  tracer: stopped\u003d1 signo\u003d19\n  mother: SIGCONT\n  tracer: stopped\u003d0 signo\u003d5\n  tracer: SIG 18\n  mother: SIGSTOP\n  tracer: SIG 19\n  tracer: stopped\u003d1 signo\u003d19\n  mother: SIGCONT\n  tracer: stopped\u003d0 signo\u003d5\n  tracer: SIG 18\n  mother: SIGSTOP\n  tracer: SIG 19\n  tracer: stopped\u003d1 signo\u003d19\n  mother: SIGCONT\n  tracer: stopped\u003d0 signo\u003d5\n  tracer: SIG 18\n\nSigned-off-by: Tejun Heo \u003ctj@kernel.org\u003e\nCc: Oleg Nesterov \u003coleg@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8bd84b83a35b34c87a66100b8087fd0d40a1af10",
      "old_mode": 33188,
      "old_path": "include/linux/sched.h",
      "new_id": "1854def284f5b0f4e1a89ad8f1591638b58a74ce",
      "new_mode": 33188,
      "new_path": "include/linux/sched.h"
    },
    {
      "type": "modify",
      "old_id": "589292f3853013ff830668a6027e7049e5409816",
      "old_mode": 33188,
      "old_path": "kernel/signal.c",
      "new_id": "06177e2b391705fa4792c5c70886e234f5c67a2c",
      "new_mode": 33188,
      "new_path": "kernel/signal.c"
    }
  ]
}
