)]}'
{
  "commit": "fca26f260c528ee51a2e451b5b200aeb528f3e09",
  "tree": "8c64ecdcece48b55e79bbb7f376a834fc99804a3",
  "parents": [
    "3544d72a0e10d0aa1c1bd59ed77a53a59cdc12f7"
  ],
  "author": {
    "name": "Tejun Heo",
    "email": "tj@kernel.org",
    "time": "Tue Jun 14 11:20:16 2011 +0200"
  },
  "committer": {
    "name": "Oleg Nesterov",
    "email": "oleg@redhat.com",
    "time": "Thu Jun 16 21:41:53 2011 +0200"
  },
  "message": "ptrace: implement PTRACE_INTERRUPT\n\nCurrently, there\u0027s no way to trap a running ptracee short of sending a\nsignal which has various side effects.  This patch implements\nPTRACE_INTERRUPT which traps ptracee without any signal or job control\nrelated side effect.\n\nThe implementation is almost trivial.  It uses the group stop trap -\nSIGTRAP | PTRACE_EVENT_STOP \u003c\u003c 8.  A new trap flag\nJOBCTL_TRAP_INTERRUPT is added, which is set on PTRACE_INTERRUPT and\ncleared when any trap happens.  As INTERRUPT should be useable\nregardless of the current state of tracee, task_is_traced() test in\nptrace_check_attach() is skipped for INTERRUPT.\n\nPTRACE_INTERRUPT is available iff tracee is attached with\nPTRACE_SEIZE.\n\nTest 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 ts100ms \u003d { .tv_nsec \u003d 100000000 };\n  static const struct timespec ts1s \u003d { .tv_sec \u003d 1 };\n  static const struct timespec ts3s \u003d { .tv_sec \u003d 3 };\n\n  int main(int argc, char **argv)\n  {\n\t  pid_t tracee;\n\n\t  tracee \u003d fork();\n\t  if (tracee \u003d\u003d 0) {\n\t\t  nanosleep(\u0026ts100ms, NULL);\n\t\t  while (1) {\n\t\t\t  printf(\"tracee: alive pid\u003d%d\\n\", getpid());\n\t\t\t  nanosleep(\u0026ts1s, NULL);\n\t\t  }\n\t  }\n\n\t  if (argc \u003e 1)\n\t\t  kill(tracee, SIGSTOP);\n\n\t  nanosleep(\u0026ts100ms, NULL);\n\n\t  ptrace(PTRACE_SEIZE, tracee, NULL,\n\t\t (void *)(unsigned long)PTRACE_SEIZE_DEVEL);\n\t  if (argc \u003e 1) {\n\t\t  waitid(P_PID, tracee, NULL, WSTOPPED);\n\t\t  ptrace(PTRACE_CONT, tracee, NULL, NULL);\n\t  }\n\t  nanosleep(\u0026ts3s, NULL);\n\n\t  printf(\"tracer: INTERRUPT and DETACH\\n\");\n\t  ptrace(PTRACE_INTERRUPT, tracee, NULL, NULL);\n\t  waitid(P_PID, tracee, NULL, WSTOPPED);\n\t  ptrace(PTRACE_DETACH, tracee, NULL, NULL);\n\t  nanosleep(\u0026ts3s, NULL);\n\n\t  printf(\"tracer: exiting\\n\");\n\t  kill(tracee, SIGKILL);\n\t  return 0;\n  }\n\nWhen called without argument, tracee is seized from running state,\ninterrupted and then detached back to running state.\n\n  # ./test-interrupt\n  tracee: alive pid\u003d4546\n  tracee: alive pid\u003d4546\n  tracee: alive pid\u003d4546\n  tracer: INTERRUPT and DETACH\n  tracee: alive pid\u003d4546\n  tracee: alive pid\u003d4546\n  tracee: alive pid\u003d4546\n  tracer: exiting\n\nWhen called with argument, tracee is seized from stopped state,\ncontinued, interrupted and then detached back to stopped state.\n\n  # ./test-interrupt  1\n  tracee: alive pid\u003d4548\n  tracee: alive pid\u003d4548\n  tracee: alive pid\u003d4548\n  tracer: INTERRUPT and DETACH\n  tracer: exiting\n\nBefore PTRACE_INTERRUPT, once the tracee was running, there was no way\nto trap tracee and do PTRACE_DETACH without causing side effect.\n\n-v2: Updated to use task_set_jobctl_pending() so that it doesn\u0027t end\n     up scheduling TRAP_STOP if child is dying which may make the\n     child unkillable.  Spotted by Oleg.\n\nSigned-off-by: Tejun Heo \u003ctj@kernel.org\u003e\nCc: Oleg Nesterov \u003coleg@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "67ad3f15232980ce964488642f46e42613efd009",
      "old_mode": 33188,
      "old_path": "include/linux/ptrace.h",
      "new_id": "ad754d1e0b135d0a67c4e3f7c7c389eba083bb17",
      "new_mode": 33188,
      "new_path": "include/linux/ptrace.h"
    },
    {
      "type": "modify",
      "old_id": "dcf9f974198c8ef98f4b2760c38ee81f3f28e6a9",
      "old_mode": 33188,
      "old_path": "kernel/ptrace.c",
      "new_id": "6852c0f4a91691f99a2ff7911d18d76535ee52d8",
      "new_mode": 33188,
      "new_path": "kernel/ptrace.c"
    }
  ]
}
