You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now for builtin/custom commands, we just call the registered functions to get the results instead of spawning separate processes. However, when they are used in pipes, it could become blocking when the pipe is full:
code:
➜ rust_cmd_lib git:(master) ✗ cat examples/one.rs
use cmd_lib::*;fnmain() -> CmdResult{init_builtin_logger();use_builtin_cmd!(cat);// remove this line, there will be no blockinglet big_file_content = "a".repeat(64*4096*2);
std::fs::write("/tmp/big_file", big_file_content)?;run_cmd!(cat /tmp/big_file | wc)?;Ok(())}
output:
➜ rust_cmd_lib git:(master) ✗ CMD_LIB_DEBUG=1 cargo run --example one Finished dev [unoptimized + debuginfo] target(s) in 0.02s Running `target/debug/examples/one`DEBUG - Running ["cat", "/tmp/big_file"] | ["wc"] ...---> blocking here
We can fix the above bug by launching threads for each builtin/custom commands, however, it seems overkill for other builtin commands like echo/true/info/error/debug/..., and it would also complicate the current code. Need to figure out a way to solve this blocking issue more gracefully.
The text was updated successfully, but these errors were encountered:
there will be 3 child handles:
1. normal process child handle for external commands
2. sync function handle for builtin/custom commands without piping
3. thread spawning handle for builtin/custom pipe-out commands
fix#22
there will be 3 child handles:
1. normal process child handle for external commands
2. sync function handle for builtin/custom commands without piping
3. thread spawning handle for builtin/custom pipe-out commands
fix#22
Right now for builtin/custom commands, we just call the registered functions to get the results instead of spawning separate processes. However, when they are used in pipes, it could become blocking when the pipe is full:
code:
output:
We can fix the above bug by launching threads for each builtin/custom commands, however, it seems overkill for other builtin commands like echo/true/info/error/debug/..., and it would also complicate the current code. Need to figure out a way to solve this blocking issue more gracefully.
The text was updated successfully, but these errors were encountered: