8000 darwin: Keep parent's end of the helper control socket out of the helper by hsorbo · Pull Request #1266 · frida/frida-core · GitHub
[go: up one dir, main page]

Skip to content

darwin: Keep parent's end of the helper control socket out of the helper - #1266

Merged
oleavr merged 1 commit into
mainfrom
fix/darwin-helper-parent-socket-cloexec
Oct 18, 2026
Merged

oleavr merged 1 commit into
mainfrom
fix/darwin-helper-parent-socket-cloexec

Conversation

@hsorbo
@hsorbo hsorbo commented Oct 17, 2026 •
Copy link
Copy Markdown
Member

The helper is spawned with LEAVE_DESCRIPTORS_OPEN so the fd carrying its end of the control socketpair survives the exec. The parent's end was not marked close-on-exec, so the helper inherited that too. When the parent went away without an orderly stop, the helper's own copy of the parent's end kept the connection alive, the connection never closed, and the helper lingered forever, along with anything it had spawned.

Mark the parent's end close-on-exec. The helper's existing shutdown path, which fires when the connection closes and the backend is idle, then takes care of the rest.

Add a test that spawns through the local device and checks the helper's descriptor table for a socket connected to another of its own descriptors.

Simple reproducer

const frida = require('frida');
const { execSync } = require('child_process');

(async () => {
  const pid = await frida.spawn(['/bin/sleep', '300']);
  const helper = execSync(`pgrep -P ${process.pid}`).toString().trim();
  console.log('node', process.pid, 'helper', helper, 'target', pid);
  console.log(execSync(`lsof -n -P -p ${helper} | grep unix`).toString());
  process.kill(process.pid, 'SIGKILL');
})();

Run it, then check the helper it printed:

node repro.cjs
ps -o pid,ppid,stat -p <helper pid>

@oleavr
oleavr force-pushed the fix/darwin-helper-parent-socket-cloexec branch from d57dfc4 to 4c78da4 Compare October 18, 2026 11:10
@oleavr
oleavr merged commit 4993c7e into main Oct 18, 2026
71 of 72 checks passed
@oleavr
oleavr deleted the fix/darwin-helper-parent-socket-cloexec branch October 18, 2026 11:11
@oleavr
oleavr commented Oct 18, 2026
Copy link
Copy Markdown
Member

w00t! Thanks! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0