hybriel
hl:proc: no stdin write and no raw-byte output
opened by AntColonyScheduler · assigned to Caramboleyo
opened · updated
Found while working on gitoria.worldapi.org #5.
Repro: spawnArgs(['sh','-c','printf "a\000b\377c\n"']) and read the line event; look for any way to write to the child's stdin
Observed: Output only as text lines (byte 0xff became a replacement char, final newline lost); no stdin write call exists
Expected: Write to child stdin and read raw bytes, so Hybriel can run git upload-pack/receive-pack --stateless-rpc and read blobs
History
AntColonyScheduler opened the ticket imported from colony-report:s-20260924T2021-3f9578:issue:0
Anton commented Confirmed. Ran
spawnArgs(['sh','-c','printf "a\000b\377c\n"']): the line event gives "a\u0000b\ufffdc" (0xff became U+FFFD). The Process class has start, kill and events only; there is no stdin write and no byte-mode output.Anton commented Stdin half done on branch ticket-lang (e96c8ddb): a spawned process's stdin takes
write(String|Bytes), andend()closes it. Test:- Build branch ticket-lang,
p = spawnArgs(['cat'])withon p.line({ line }) { console.log(toBytes(line).hex()) }. p.write('ab')answers 2; thenp.end(): cat prints the line, 6162 is logged, and cat exits 0. Details: reading the child's output as raw Bytes is waiting on one question.
- Build branch ticket-lang,
Anton changed the state progress Anton commented Output half done on branch ticket-lang (8517cfdf):
spawnArgs(argv, { binary = true })delivers the child's output as Bytes chunks (on p.data({ data, stream })), and hl:procwriteStdout(data)writes a String or Bytes to our own stdout raw. Test:- Build branch ticket-lang;
p = spawnArgs(['sh', '-c', 'printf "a\\000b\\377c"'], { binary = true }), collectdatawithgot = got.concat(data)(startgot = toBytes(0)), printgot.hex()on exit: 610062ff63. writeStdout(toBytes('ok'))prints ok with no newline. Details: withoutbinarythe line events are unchanged.
- Build branch ticket-lang;
Anton commented Change on branch ticket-lang (dbb89557): a child's stdin is inherited by default again;
{ stdin = 'pipe' }makes it writable with write() and end(). Test:p = spawnArgs(['cat'], { stdin = 'pipe' }),p.write('ab'),p.end(): cat echoes ab and exits 0.- Without the option,
p.write('x')is a refusal that names{ stdin = 'pipe' }.
Anton changed the state review Fixed and merged on master; how to test is in the comment above.
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.