nikivdev/code · warning
Specify a task name, --pid <pid>, or --all
Error message
Specify a task name, --pid <pid>, or --all
What it means
The `kill` command requires the caller to select what to kill: a task name, a PID via --pid, or everything via --all. If none of these is provided, kill_processes bails with this usage guidance instead of guessing. It is a user-input validation error, not an internal failure.
Source
Thrown at src/processes.rs:115
format!("{}m {}s", elapsed_secs / 60, elapsed_secs % 60)
} else {
format!("{}h {}m", elapsed_secs / 3600, (elapsed_secs % 3600) / 60)
}
}
/// Kill processes based on options
pub fn kill_processes(opts: KillOpts) -> Result<()> {
let (config_path, _cfg) = tasks::load_project_config(opts.config)?;
let canonical = config_path.canonicalize()?;
if let Some(pid) = opts.pid {
kill_by_pid(pid, opts.force, opts.timeout)
} else if let Some(task) = &opts.task {
kill_by_task(&canonical, task, opts.force, opts.timeout)
} else if opts.all {
kill_all_for_project(&canonical, opts.force, opts.timeout)
} else {
bail!("Specify a task name, --pid <pid>, or --all")
}
}
fn kill_by_pid(pid: u32, force: bool, timeout: u64) -> Result<()> {
let processes = running::load_running_processes()?;
// Find the process entry to get its PGID
let entry = processes.projects.values().flatten().find(|p| p.pid == pid);
let pgid = entry.map(|e| e.pgid).unwrap_or(pid);
let task_name = entry.map(|e| e.task_name.as_str()).unwrap_or("unknown");
terminate_process_group(pgid, force, timeout)?;
running::unregister_process(pid)?;
println!("Killed {} (pid: {}, pgid: {})", task_name, pid, pgid);
Ok(())
}View on GitHub (pinned to a747e741ae)
Solutions
- Pass the task name: `f kill <task>`.
- Or target a specific process: `f kill --pid <pid>`.
- Or kill everything for the project: `f kill --all`.
- List current targets first with `f ps` to decide what to kill.
Example fix
// before (shell script)
f kill $TASK
// after
TASK="${TASK:?set TASK or pass an explicit kill target}"
f kill "$TASK" Defensive patterns
Strategy: validation
Validate before calling
// check args before invoking the CLI
let args: Vec<String> = std::env::args().skip(1).collect();
if !args.iter().any(|a| a == "--all" || a == "--pid") && args.len() < 2 {
eprintln!("usage: f kill <task> | --pid <pid> | --all");
std::process::exit(2);
} Try / catch
match kill_processes(opts) {
Ok(()) => (),
Err(e) if e.to_string().contains("Specify a task name") => {
eprintln!("{e}");
std::process::exit(2); // usage error, not a runtime failure
}
Err(e) => return Err(e),
} Prevention
- Always pass one of: task name, --pid, or --all.
- Add shell completion or a wrapper that rejects empty kill targets.
- Guard scripts with ${VAR:?} for interpolated task names/pids.
When it happens
Trigger: Invoking `f kill` (or calling kill_processes with opts.task=None, opts.pid=None, opts.all=false) — i.e., no targeting flag at all on the command line.
Common situations: Typing `f kill` with no arguments, forgetting that task name must be positional, or scripting the command with an empty variable where the task name should be.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- No command specified
- Specify a todo id or use --all to fix all open review todos
- No prompt provided. Usage: f agents run {} "your prompt here
- sessions requires a specific provider (claude or codex)
- continue requires a specific provider (claude or codex)
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/5897ef855e02de8a.
Report an issue: GitHub.