From 04faf33542104883ff27ef83d0a03df2c3189bdc Mon Sep 17 00:00:00 2001 From: ge Date: Thu, 8 Jan 2026 05:12:41 +0300 Subject: [PATCH] examples: update command_with_timeout.v, remove io.string_reader from write_to_child_string.v --- examples/command_with_timeout.v | 7 ++++--- examples/write_to_child_stdin.v | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/command_with_timeout.v b/examples/command_with_timeout.v index aee8071..33f4c36 100644 --- a/examples/command_with_timeout.v +++ b/examples/command_with_timeout.v @@ -11,16 +11,17 @@ fn main() { mut cmd := runcmd.with_context(ctx, 'sleep', '120') // Start a command. - started := time.now() - println('Start command at ${started}') cmd.start()! + started := time.now() + println('Command started at ${started}') // Wait for command. cmd.wait()! // The `sleep 120` command would run for two minutes without a timeout. // But in this example, it will time out after 10 seconds. - println('Command finished after ${time.now() - started}') + finished := time.now() + println('Command finished at ${finished} after ${finished - started}') // Since command has been terminated, the state would be: `signal: 15 (SIGTERM)` println('Child state: ${cmd.state}') diff --git a/examples/write_to_child_stdin.v b/examples/write_to_child_stdin.v index 5576db8..09ce1ce 100644 --- a/examples/write_to_child_stdin.v +++ b/examples/write_to_child_stdin.v @@ -1,4 +1,3 @@ -import io.string_reader import strings import runcmd @@ -6,12 +5,11 @@ fn main() { input := 'Hello from parent process!' // Prepare reader and writer. - // // * `reader` reads input from the parent process; it will be copied to the // standard input of the child process. // * `writer` accepts data from the child process; it will be copied from the // standard output of the child process. - mut reader := string_reader.StringReader.new(reader: runcmd.buffer(input.bytes()), source: input) + mut reader := runcmd.buffer(input.bytes()) mut writer := strings.new_builder(4096) // Prepare the command.