{
 "number": 35887,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/35887",
 "title": "ipc: use std::optional for checkSpawned(), add tests and rename arg -ipcfd to -ipcchild",
 "author": "ViniciusCestarii",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-08-04T20:47:35Z",
 "updated_at": "2026-09-16T16:19:13Z",
 "age_days": 43,
 "draft": false,
 "labels": [
  "IPC"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "05e7d573184079720e11d933d24b9c9228477a14",
 "head_ref": "checkspawned-tests",
 "head_repo": "ViniciusCestarii/bitcoin",
 "head_history": [
  {
   "t": "2026-08-17T13:12:50Z",
   "sha": "60c43329aa0f50c1bc6b801b858ebb13425fd971"
  },
  {
   "t": "2026-08-18T00:22:49Z",
   "sha": "05e7d573184079720e11d933d24b9c9228477a14"
  }
 ],
 "additions": 67,
 "deletions": 24,
 "changed_files": 6,
 "commit_count": 3,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "ack": [
     {
      "login": "jeanpablojp",
      "url": "https://github.com/bitcoin/bitcoin/pull/35887#issuecomment-5348880153"
     },
     {
      "login": "enirox001",
      "url": "https://github.com/bitcoin/bitcoin/pull/35887#pullrequestreview-5225275103"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "enirox001": {
   "kind": "ack",
   "hash": null,
   "t": "2026-09-16T16:14:38Z",
   "stale": false
  },
  "jeanpablojp": {
   "kind": "ack",
   "hash": "05e7d573184079720e11d933d24b9c9228477a14",
   "t": "2026-08-19T22:43:10Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 2,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "enirox001",
   "jeanpablojp"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-08-18T00:24:27Z",
  "last_reviewer_activity": "2026-09-16T16:14:38Z",
  "last_reviewer": "enirox001",
  "author_silent_days": 30,
  "waiting_on_author_days": 1,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [
   35084
  ],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [
   {
    "number": 35084,
    "type": "pull",
    "state": "closed",
    "merged": true,
    "merged_at": "2026-07-29",
    "title": "ipc: Add nonunix platform support"
   }
  ],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "src/ipc/test/ipc_tests.cpp"
 ],
 "body": "Implement proposed follow-ups on dicussion https://github.com/bitcoin/bitcoin/pull/35084#discussion_r3664894660:\n\nDiscussion\n\n[Sjors](https://github.com/Sjors):\n\nIn https://github.com/bitcoin/bitcoin/commit/2d3f72fd3fa45ab4e399094c39bfa93bb5a87323 ipc, refactor: Update mp::SpawnProcess call: suggested test coverage:\n\nBOOST_AUTO_TEST_CASE(check_spawned_test)\n{\n    std::unique_ptr<ipc::Process> process{ipc::MakeProcess()};\n    mp::SocketId socket{mp::SocketError};\n    char arg0[]{\"bitcoin-node\"};\n    char arg1[]{\"-ipcfd\"};\n    char arg2[]{\"invalid\"};\n    char* argv[]{arg0, arg1, arg2};\n    auto check_error{[](const std::runtime_error& e) {\n        return std::string_view{e.what()}.starts_with(\"Invalid -ipcfd number 'invalid'\");\n    }};\n    BOOST_CHECK_EXCEPTION(process->checkSpawned(3, argv, socket), std::runtime_error, check_error);\n    BOOST_CHECK_EQUAL(socket, mp::SocketError);\n}\n\n[ryanofsky](https://github.com/ryanofsky):\n\nre: https://github.com/bitcoin/bitcoin/pull/35084#discussion_r3664894660\n\nThis is a good test suggestion that would be a nice followup. Note that after https://github.com/bitcoin-core/libmultiprocess/pull/274, the exception will be a little different and look more like \"StartSpawned: invalid connect_info\" and after https://github.com/bitcoin-core/libmultiprocess/pull/231 the exception on windows will be \"CreateFile(pipe) failed\" so it could make sense to just check that an exception is thrown and not try to match the text.\n\nAlso:\n\nIt would be nice to change checkSpawned signature to return optional<SocketId> instead of using bool and an output parameter. (I believe this code is from before C++17 which added std::optional)\nCould be good to add another test case that doesn't pass an -ipcfd and ensures checkSpawned returns false without throwing an exception.\nCould be good to add another test case that just passes -ipcfd as the last argument.\nCould be nice to rename -ipcfd to something more generic like -ipcspawn or -ipcchild since a named pipe path instead of a file descriptor is passed on windows.\n\n- Add unit test for checkSpawned().\n- Make checkSpawned() return std::optional<mp::SocketId>.\n- Rename -ipcfd to -ipcchild.",
 "commits": [
  {
   "sha": "bd3a38f10ab7ef44a0f8e8626edf022831aa7e74",
   "date": "2026-08-04T20:33:34Z",
   "message": "ipc, refactor: return std::optional<mp::SocketId> from checkSpawned()"
  },
  {
   "sha": "8bca7555f8328851bff0bf50d3bbdaa57aaac4b1",
   "date": "2026-08-04T20:34:10Z",
   "message": "ipc, refactor: rename arg -ipcfd to -ipcchild"
  },
  {
   "sha": "05e7d573184079720e11d933d24b9c9228477a14",
   "date": "2026-08-18T00:22:39Z",
   "message": "ipc, test: add checkSpawned() unit tests"
  }
 ],
 "timeline": [
  {
   "t": "2026-08-11T09:14:56Z",
   "kind": "review",
   "who": "enirox001",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "d01e65ccffe4f195789cf8aa6c7b9d60a72c877d",
   "text": "Concept ACK\n\nWould be helpful if you linked the comments for the follow-ups in the PR description as that could aid with review"
  },
  {
   "t": "2026-08-16T16:54:28Z",
   "kind": "review",
   "who": "jeanpablojp",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "d01e65ccffe4f195789cf8aa6c7b9d60a72c877d",
   "text": "Approach ACK d01e65ccffe4f195789cf8aa6c7b9d60a72c877d\n\nI have tested the code with IPC enabled and it is ok. I confirm that the follow-ups ryanofsky requested in #35084 were implemented. I left an inline suggestion for one more `check_spawned_test` case."
  },
  {
   "t": "2026-08-16T16:54:28Z",
   "kind": "review_comment",
   "who": "jeanpablojp",
   "assoc": "CONTRIBUTOR",
   "path": "src/ipc/test/ipc_tests.cpp",
   "commit": "05e7d573184079720e11d933d24b9c9228477a14",
   "in_reply_to": null,
   "text": "I think one case is missing: the negative cases all bail on `argc != 3`, so the `strcmp` never really runs. Tested locally without that half and the suite passed. Something like `bitcoin-node -regtest -daemon`, three arguments without `-ipcchild`, would cover it:\n\n```cpp\n    // three arguments, but the first is not -ipcchild.\n    {\n        char* argv[]{arg0, arg_other, arg_invalid};\n        BOOST_CHECK(!process->checkSpawned(3, argv));\n    }\n```"
  },
  {
   "t": "2026-08-17T13:12:50Z",
   "kind": "force_push",
   "who": "ViniciusCestarii",
   "commit": "60c43329aa0f50c1bc6b801b858ebb13425fd971"
  },
  {
   "t": "2026-08-17T13:14:12Z",
   "kind": "review_comment",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "path": "src/ipc/test/ipc_tests.cpp",
   "commit": "05e7d573184079720e11d933d24b9c9228477a14",
   "in_reply_to": 3792274773,
   "text": "Nice catch, thanks for reviewing. Done 60c43329aa0f50c1bc6b801b858ebb13425fd971"
  },
  {
   "t": "2026-08-17T13:15:59Z",
   "kind": "comment",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "text": "Thanks for the reviews! Forced-push 60c43329aa0f50c1bc6b801b858ebb13425fd971 adding a new unit test suggested."
  },
  {
   "t": "2026-08-18T00:22:49Z",
   "kind": "force_push",
   "who": "ViniciusCestarii",
   "commit": "05e7d573184079720e11d933d24b9c9228477a14"
  },
  {
   "t": "2026-08-18T00:24:27Z",
   "kind": "comment",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "text": "Forced push 05e7d573184079720e11d933d24b9c9228477a14 to rerun ci because some failed due to [a github incident](https://www.githubstatus.com/incidents/zkxwbgr0cnmx)."
  },
  {
   "t": "2026-08-19T22:43:10Z",
   "kind": "comment",
   "who": "jeanpablojp",
   "assoc": "CONTRIBUTOR",
   "text": "ACK 05e7d573184079720e11d933d24b9c9228477a14"
  },
  {
   "t": "2026-09-16T16:14:38Z",
   "kind": "review",
   "who": "enirox001",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "05e7d573184079720e11d933d24b9c9228477a14",
   "text": "utACK https://github.com/bitcoin/bitcoin/pull/35887/changes/05e7d573184079720e11d933d24b9c9228477a14\n\n~~I am wondering could we squash https://github.com/bitcoin/bitcoin/pull/35887/changes/05e7d573184079720e11d933d24b9c9228477a14 into https://github.com/bitcoin/bitcoin/pull/35887/changes/bd3a38f10ab7ef44a0f8e8626edf022831aa7e74 (the commit that introduces the changes)?~~\n\n~~It would be better if we kept the changes as self contained testable units when we can.~~\n\nOops, saw that the tests use the `ipcchild` that was introduced in the 2nd commit, so trying to squash them would mean we would have to squash everything into a single commit, The commit structure is good as is"
  }
 ],
 "labels_log": [
  {
   "t": "2026-08-04T20:47:39Z",
   "action": "labeled",
   "label": "IPC",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 4337,
 "text_tokens_estimate": 1084,
 "changed_paths": [
  "src/bitcoin.cpp",
  "src/ipc/interfaces.cpp",
  "src/ipc/process.cpp",
  "src/ipc/process.h",
  "src/ipc/test/ipc_tests.cpp",
  "test/lint/check-doc.py"
 ],
 "files": [
  {
   "path": "src/bitcoin.cpp",
   "add": 1,
   "del": 1
  },
  {
   "path": "src/ipc/interfaces.cpp",
   "add": 4,
   "del": 3
  },
  {
   "path": "src/ipc/process.cpp",
   "add": 16,
   "del": 16
  },
  {
   "path": "src/ipc/process.h",
   "add": 4,
   "del": 3
  },
  {
   "path": "src/ipc/test/ipc_tests.cpp",
   "add": 41,
   "del": 0
  },
  {
   "path": "test/lint/check-doc.py",
   "add": 1,
   "del": 1
  }
 ],
 "test_lines": 2,
 "git": {
  "head": "05e7d573184079720e11d933d24b9c9228477a14",
  "head_matches_backup": true,
  "base": "17c5e33e9c5418fb0240f5d4210c87f54b88cdda",
  "commits": [
   {
    "sha": "bd3a38f10a",
    "subject": "ipc, refactor: return std::optional<mp::SocketId> from checkSpawned()",
    "files": 3,
    "add": 21,
    "del": 19
   },
   {
    "sha": "8bca7555f8",
    "subject": "ipc, refactor: rename arg -ipcfd to -ipcchild",
    "files": 3,
    "add": 8,
    "del": 8
   },
   {
    "sha": "05e7d57318",
    "subject": "ipc, test: add checkSpawned() unit tests",
    "files": 1,
    "add": 41,
    "del": 0
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "ae4bd06b30569149",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}