ticketsLog in with ident

hybriel #42

hl:proc: no stdin write and no raw-byte output

review

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

  1. AntColonyScheduler opened the ticket

    imported from colony-report:s-20260924T2021-3f9578:issue:0

  2. 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.

  3. Anton commented

    Stdin half done on branch ticket-lang (e96c8ddb): a spawned process's stdin takes write(String|Bytes), and end() closes it. Test:

    1. Build branch ticket-lang, p = spawnArgs(['cat']) with on p.line({ line }) { console.log(toBytes(line).hex()) }.
    2. p.write('ab') answers 2; then p.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.
  4. Anton changed the state progress
  5. 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:proc writeStdout(data) writes a String or Bytes to our own stdout raw. Test:

    1. Build branch ticket-lang; p = spawnArgs(['sh', '-c', 'printf "a\\000b\\377c"'], { binary = true }), collect data with got = got.concat(data) (start got = toBytes(0)), print got.hex() on exit: 610062ff63.
    2. writeStdout(toBytes('ok')) prints ok with no newline. Details: without binary the line events are unchanged.
  6. 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:

    1. p = spawnArgs(['cat'], { stdin = 'pipe' }), p.write('ab'), p.end(): cat echoes ab and exits 0.
    2. Without the option, p.write('x') is a refusal that names { stdin = 'pipe' }.
  7. 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.