)]}'
{
  "commit": "203b59e710b9e7d033e517ce99010147d40705e3",
  "tree": "efc883d45d398c269d6c502d966dd8db394817fc",
  "parents": [
    "fcff28da5f6f55dd35bd5090b43688e80c594889"
  ],
  "author": {
    "name": "David \u0027Digit\u0027 Turner",
    "email": "digit@google.com",
    "time": "Thu Apr 23 19:26:14 2026 +0200"
  },
  "committer": {
    "name": "David \u0027Digit\u0027 Turner",
    "email": "digit@google.com",
    "time": "Fri Apr 24 11:03:44 2026 +0200"
  },
  "message": "Refine the way Ninja waits for subprocess completion.\n\nThis CL refactors how the Posix SubprocessSet implementation\ndelays with subprocess completion. Before this CL, the\nFuchsia version of Ninja would always wait for the output\npipe of a command to be closed to determine that the\ncorresponding \"work\" has completed.\n\nThis is important because a command sub-process can launch\nchild programs in the background and passing them their\nstdout/stderr descriptors, and may exit *before* the child\nitself.\n\nHowever, this doesn\u0027t work in certain cases, for example if\nthe child process daemonizes itself, and keeps the output\ndescriptor opened, without writing anything to it. It is\nsuspected that this is the root cause of the Ninja\nbuild timeouts that were are experiencing in CI (see\nassociated bug).\n\nAs a work-around, this CL changes the logic to used by\nNinja to the following:\n\n- Each Subprocess instance can be in one of three\n  states now:\n\n  * Running: its PID is active, and its pipe is open.\n\n  * Reaped: the PID has exited, but the pipe is still\n    open and Ninja is waiting for more data out of it.\n\n  * Finished: the PID has exited, and the pipe is\n    closed.\n\n  NOTE: The special case where the Subprocess has no\n  pipe is no longer enabled in the Fuchsia version of\n  Ninja, but corresponds to the upstream behavior\n  for \"console\" processes. This didn\u0027t allow recording\n  their output though.\n\n- When the pipe is closed, the Subprocess is reaped\n  and finished immediately.\n\n- SIGCHLD is used to detect when any Subprocess PID exits\n  and reaps it immediately (before that it would only\n  check for upstream console processes). However, if\n  the pipe is still open, a timer is setup to wait up\n  to 30 seconds for incoming data on the pipe, and\n  the Subprocess is kept in the running_ queue\n  (but with \u0027reaped_ \u003d\u003d true\u0027).\n\n- When data arrives on the pipe of a reaped process,\n  the timer is re-armed to wait for 30 more seconds\n  (just in case).\n\n- Otherwise, if the timer expires, the Subprocess\n  is force-finished.\n\n- A SIGINT / SIGTERM / SIGHUP should also force-finish\n  reaped Subprocess instances immediately.\n\n+ Adjust the process tree to print \"REAPED [PID \u003cpid\u003e]\"\n  instead of \"[PID \u003cpid\u003e]\" when printing the command\n  corresponding to a Reaped Subprocess instance.\n\n+ Add a regression test that verifies that SIGINT\n  stops Ninja immediately when it is waiting for\n  a reaped subprocess.\n\n+ Add a regression test that verifies that SIGTERM\n  stops Ninja immediately when it is waiting for\n  a reaped subprocess, and that the diagnostic\n  message lists its pid with the REAPED tag.\n\nBug: 498320348\nFuchsia-Only: graceful-shutdown\nChange-Id: Ic7e81aca2680fdc603873227be7b7515d8969248\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "34bc7b606ce4044bec8fcf1bd7bcb848575431e9",
      "old_mode": 33188,
      "old_path": "misc/fuchsia/fuchsia_features_test.py",
      "new_id": "9451755e6b5c047f2fc93aebb350fca3650bcdce",
      "new_mode": 33188,
      "new_path": "misc/fuchsia/fuchsia_features_test.py"
    },
    {
      "type": "modify",
      "old_id": "71076452b5c6ba32055602c307dbddf2c704e3b3",
      "old_mode": 33188,
      "old_path": "src/subprocess-posix.cc",
      "new_id": "14384421596c73a58d6391562990217dab4196fc",
      "new_mode": 33188,
      "new_path": "src/subprocess-posix.cc"
    },
    {
      "type": "modify",
      "old_id": "84f6f976d3f76b9f9855df1ff778171859bc297e",
      "old_mode": 33188,
      "old_path": "src/subprocess.h",
      "new_id": "7ceef84309478726724072cc24339bff8b11e4c0",
      "new_mode": 33188,
      "new_path": "src/subprocess.h"
    },
    {
      "type": "modify",
      "old_id": "2ca8b19303fc0dac70cbe66a45a14b157380da11",
      "old_mode": 33188,
      "old_path": "src/subprocess_test.cc",
      "new_id": "9f89591a35472053146ba766a1154e5edf851cb0",
      "new_mode": 33188,
      "new_path": "src/subprocess_test.cc"
    }
  ]
}
