Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/sdk/src/named-gate-lowering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ process.exit(result.status===0?0:1);`;
body = `const result=cp.spawnSync('wc',['-w'],{input:text,encoding:'utf8',env:{...process.env,LC_ALL:'C'}});
const noise=(result.stderr||'').trim().slice(-200);
const said=noise===''?'':': '+noise;
if(result.error)fail('could not run wc -w: '+(result.error.code||result.error.message)+said);
if(result.signal)fail('wc -w was terminated by '+result.signal+said);
if(result.status!==null){
if(result.status!==0)fail('wc -w exited '+result.status+said);
}else if(result.error){
fail('could not run wc -w: '+(result.error.code||result.error.message)+said);
}
const count=result.stdout.trim();
if(!/^[0-9]+$/.test(count))fail('wc -w printed '+JSON.stringify(count.slice(0,80))+' instead of a word count'+said);
process.stdout.write(BigInt(count).toString());`;
Expand Down
15 changes: 15 additions & 0 deletions packages/sdk/tests/named-gate-diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,19 @@ describe('word_count_bounds reports why its own child failed', () => {
expect(capture.status).toBe(1);
expect(capture.stderr).toContain('SIGKILL');
});

it('does not report EPIPE when wc exits nonzero after closing stdin', () => {
const path = stubWordCount('exit 2');
const largeInput = 'x'.repeat(100_000);

const capture = runGate(
command(),
{ output: deterministicEnvelope(largeInput) },
{ path },
);

expect(capture.status).toBe(1);
expect(capture.stderr).toContain('exited 2');
expect(capture.stderr).not.toContain('EPIPE');
});
});
Loading