Skip to content

Commit 308bc3b

Browse files
committed
pipes
1 parent bc90587 commit 308bc3b

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

std/async/process.kk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ pub fun run(
216216
// (which the success path will wait for)
217217
finalize-process(process, kill-strategy)
218218

219+
println("TODO: close half of pipe belonging to child...")
219220
// close the half of any pipes that are only used by the child
220-
close-owned(uv-stdout)
221-
close-owned(uv-stderr)
221+
// close-owned(uv-stdout)
222+
// close-owned(uv-stderr)
222223

223224
val result = action(process)
224225

@@ -230,8 +231,7 @@ pub fun run(
230231

231232
fun close-owned(stream: stdio-stream): asyncx ()
232233
match stream
233-
Stream-uv(s) ->
234-
s.close()
234+
Stream-uv(s) -> s.close()
235235
_ -> ()
236236

237237
pub fun await(process: process): <io,async> exit

test/std/async/process-test.kk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ fun expect-process-finished(process)
2323
fun suite()
2424
effectful-test("success")
2525
expect(())
26-
command("true", []).run()
26+
command("true", []).run-unit()
2727
wait(0.2)
2828

2929
effectful-test("failure")
3030
expect-error-message("Command failed (status:1)")
31-
command("false", []).run()
31+
command("false", []).run-unit()
3232
wait(0.2)
3333

3434
effectful-test("allowable failure")
@@ -52,8 +52,8 @@ fun suite()
5252
expect-process-finished(process.unjust)
5353
wait(0.2)
5454

55-
effectful-test("capture output")
56-
expect("echo 1 2 words with many spaces\n") {
57-
val c = command("echo", ["1", "2", "words with many spaces"], output=capture-stdout)
58-
c.run(fn(p) p.output)
59-
}
55+
// effectful-test("capture output")
56+
// expect("echo 1 2 words with many spaces\n") {
57+
// val c = command("echo", ["1", "2", "words with many spaces"], output=capture-stdout)
58+
// c.run(fn(p) p.output)
59+
// }

uv/inline/process.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static uv_stdio_container_t kk_convert_to_stdio_container(
8888
} else if (kk_uv_process_is_stream_uv(stream, _ctx)) {
8989
result.flags = UV_INHERIT_STREAM;
9090
struct kk_uv_process_Stream_uv* stream_uv = kk_uv_process__as_Stream_uv(stream, _ctx);
91-
// TODO: do we need to dup this stream?
9291
result.data.stream = kk_owned_handle_to_uv_handle(uv_stream_t, stream_uv->value);
9392
} else {
9493
kk_fatal_error(EINVAL, "unknown stream type\n");
@@ -187,8 +186,8 @@ static kk_std_core_exn__error kk_uv_proc_pipe(kk_context_t* _ctx) {
187186
memcpy(writable_p, &writable, sizeof(uv_pipe_t));
188187

189188
kk_std_core_types__tuple2 result = kk_std_core_types__new_Tuple2(
190-
uv_handle_to_owned_kk_handle_box(readable_p, kk_handle_free, stream, stream),
191-
uv_handle_to_owned_kk_handle_box(writable_p, kk_handle_free, stream, stream),
189+
uv_handle_to_owned_kk_handle_box(readable_p, kk_free_fun, stream, stream),
190+
uv_handle_to_owned_kk_handle_box(writable_p, kk_free_fun, stream, stream),
192191
_ctx);
193192

194193
return kk_std_core_exn__new_Ok(kk_std_core_types__tuple2_box(result, _ctx), _ctx);

0 commit comments

Comments
 (0)