Skip to content

Make iprof a transparent stdio wrapper#513

Merged
TApplencourt merged 1 commit into
develfrom
iprof-transparent-stdio
Jun 23, 2026
Merged

Make iprof a transparent stdio wrapper#513
TApplencourt merged 1 commit into
develfrom
iprof-transparent-stdio

Conversation

@TApplencourt

Copy link
Copy Markdown
Collaborator

iprof ran the user binary via IO.popen, which connects the child's stdout to a pipe. The child's libc then sees a non-tty and switches to full block-buffering, so its output only appeared once it exited (e.g. all of iprof -m full ./a.out arrived in one block instead of streaming).

Let the child inherit iprof's own stdout/stderr directly instead, so it sees exactly the descriptors iprof was given and picks the same buffering it would without iprof: line-buffered (streaming) on a terminal, block-buffered on a pipe/file. This also keeps stdout and stderr on their own streams.

Add an integration test driving iprof under a PTY (via script) to check streaming with a real libc-buffered binary, and one checking stdout/stderr stay separate. The previous test used bash echo, which is not libc-buffered and so never exercised the bug.

iprof ran the user binary via IO.popen, which connects the child's stdout
to a pipe. The child's libc then sees a non-tty and switches to full
block-buffering, so its output only appeared once it exited (e.g. all of
`iprof -m full ./a.out` arrived in one block instead of streaming).

Let the child inherit iprof's own stdout/stderr directly instead, so it
sees exactly the descriptors iprof was given and picks the same buffering
it would without iprof: line-buffered (streaming) on a terminal,
block-buffered on a pipe/file. This also keeps stdout and stderr on their
own streams.

Add an integration test driving iprof under a PTY (via `script`) to check
streaming with a real libc-buffered binary, and one checking stdout/stderr
stay separate. The previous test used `bash echo`, which is not
libc-buffered and so never exercised the bug.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TApplencourt TApplencourt merged commit dc4c813 into devel Jun 23, 2026
28 checks passed
@TApplencourt

Copy link
Copy Markdown
Collaborator Author

Superb fix.

@TApplencourt TApplencourt deleted the iprof-transparent-stdio branch June 23, 2026 22:42
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.

1 participant