MCPcopy Create free account
hub / github.com/astercloud/aster / getSignalNumber

Method getSignalNumber

pkg/tools/builtin/killshell.go:243–266  ·  view source on GitHub ↗

getSignalNumber 获取信号编号

(signal string)

Source from the content-addressed store, hash-verified

241
242// getSignalNumber 获取信号编号
243func (t *KillShellTool) getSignalNumber(signal string) int {
244 signalMap := map[string]int{
245 "SIGTERM": 15,
246 "SIGKILL": 9,
247 "SIGINT": 2,
248 "SIGHUP": 1,
249 "SIGQUIT": 3,
250 "SIGSTOP": 19,
251 "SIGCONT": 18,
252 }
253
254 if num, exists := signalMap[signal]; exists {
255 return num
256 }
257
258 // 尝试解析数字
259 var num int
260 if _, err := fmt.Sscanf(signal, "%d", &num); err == nil {
261 return num
262 }
263
264 // 默认使用SIGTERM
265 return 15
266}
267
268// waitForProcessExit 等待进程退出
269func (t *KillShellTool) waitForProcessExit(ctx context.Context, pid int, timeoutSeconds int, tc *tools.ToolContext) int {

Callers 1

ExecuteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected