mirror of
https://github.com/gechandesu/runcmd.git
synced 2026-01-23 14:54:13 +03:00
examples: update command_with_timeout.v, remove io.string_reader from write_to_child_string.v
This commit is contained in:
@@ -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}')
|
||||
|
||||
Reference in New Issue
Block a user