Conversation
This comment was marked as outdated.
This comment was marked as outdated.
| .env("HOTDATA_WORKSPACE", workspace_id) | ||
| .status(); | ||
|
|
||
| match status { |
There was a problem hiding this comment.
P2 — Signal exit code lost.
s.code() returns None when the child is killed by a signal (e.g. SIGINT from Ctrl-C), so the wrapper exits 1 instead of the conventional 128+signal. Scripts that inspect the exit code (e.g. if [ $? -eq 130 ]) will misbehave.
On Unix, the idiomatic fix is to re-raise the signal so the parent shell sees the process as signal-killed:
| match status { | |
| Ok(s) => { | |
| #[cfg(unix)] | |
| if let Some(sig) = std::os::unix::process::ExitStatusExt::signal(&s) { | |
| // Re-raise so the parent shell sees a signal-killed exit | |
| unsafe { libc::raise(sig) }; | |
| } | |
| std::process::exit(s.code().unwrap_or(1)) | |
| } |
If pulling in libc is undesirable, exiting with 128 + signal is the next-best option.
| let name = proc.name().to_string_lossy(); | ||
| if name == "hotdata" { | ||
| if proc.cmd().iter().any(|a| a == "sessions") | ||
| && proc.cmd().iter().any(|a| a == "run") |
There was a problem hiding this comment.
P2 (theoretical) — Arg matching is position-independent.
any(|a| a == "sessions") && any(|a| a == "run") matches any hotdata process that has both tokens anywhere in its argv — e.g. hotdata sessions new --name run. In practice none of the other sessions subcommands spawn child hotdata processes, so this can't actually trigger a false positive today. But it's fragile: a future subcommand that accepts free-form string args and spawns children would silently break.
Prefer a positional check on the subcommand slots:
| let name = proc.name().to_string_lossy(); | |
| if name == "hotdata" { | |
| if proc.cmd().iter().any(|a| a == "sessions") | |
| && proc.cmd().iter().any(|a| a == "run") | |
| if name == "hotdata" { | |
| let args: Vec<_> = proc.cmd().iter().skip(1).collect(); // skip argv[0] | |
| if args.first().map(|a| a.as_encoded_bytes()) == Some(b"sessions") | |
| && args.get(1).map(|a| a.as_encoded_bytes()) == Some(b"run") | |
| { | |
| return Some(pid); | |
| } | |
| } |
No description provided.