Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var KillCmd = &cobra.Command{ Use: "kill", Short: "Find and kill processes by port or PID", Long: `Terminate processes listening on a port or running under a PID, with interactive pickers and dry-run support.`, RunE: func(cmd *cobra.Command, _args []string) error { return cmd.Help() }, }
KillCmd groups process termination helpers (by port or PID).
View Source
var KillPortCmd = &cobra.Command{ Use: "port [port]", Aliases: []string{"kill-port", "killPort"}, Short: "Find and kill the process listening on a specific port", Long: `Find the process listening on the specified port and terminate it. Prompts for confirmation unless --yes is given. Use --dry-run to preview, --signal to choose a gentler signal (default 9 SIGKILL), --interactive to pick from a list.`, Example: ` eng kill port 3000 --dry-run eng kill port 3000,8080 --yes eng kill port --interactive`, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { isVerbose := cmdutil.IsVerbose(cmd) var portList []string if len(args) == 0 || interactive { log.Message("Listing listening ports...") ports, err := listPorts(filter) if err != nil { log.Error("Failed to list ports: %v", err) return } if len(ports) == 0 { log.Warn("No listening ports found.") return } selectedPort, err := selectPort(ports) if err != nil { log.Error("Failed to select port: %v", err) return } portList = []string{selectedPort.Port} } else { log.Message("Parsing ports: %s", args[0]) var errs []error portList, errs = parsePortList(args[0]) if len(errs) > 0 { log.Error("Found %d problem(s) in port list %q:", len(errs), args[0]) for _, err := range errs { log.Error(" - %v", err) } return } } for _, portStr := range portList { killPort(portStr, signal, isVerbose, killDryRun, killAssumeYes) } }, }
View Source
var KillProcessCmd = &cobra.Command{ Use: "process [pid]", Aliases: []string{"killProcess", "kill-process", "ps"}, Short: "Find and kill a process by PID or interactively", Long: `This command finds and kills a process by its PID, or lists processes for interactive selection. A comma-separated list of PIDs may be provided to kill multiple processes, e.g. "eng kill process 1234,5678". If no PID is provided or --interactive is used, it lists running processes for selection. Requires 'ps' and 'kill' commands to be available on the system. Primarily intended for Unix-like systems (Linux, macOS).`, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { isVerbose := cmdutil.IsVerbose(cmd) var pidList []string if len(args) == 0 || processInteractive { log.Message("Listing running processes...") processes, err := listProcesses(processFilter) if err != nil { log.Error("Failed to list processes: %v", err) return } if len(processes) == 0 { log.Warn("No processes found.") return } selectedProcess, err := selectProcess(processes) if err != nil { log.Error("Failed to select process: %v", err) return } pidList = []string{selectedProcess.PID} } else { log.Message("Parsing process PIDs: %s", args[0]) var errs []error pidList, errs = parseProcessList(args[0]) if len(errs) > 0 { log.Error("Found %d problem(s) in process PID list %q:", len(errs), args[0]) for _, err := range errs { log.Error(" - %v", err) } return } } for _, pidStr := range pidList { killProcess(pidStr, processSignal, isVerbose) } }, }
Functions ¶
This section is empty.
Types ¶
type ProcessInfo ¶
Click to show internal directories.
Click to hide internal directories.