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

Method isProcessRunning

pkg/tools/builtin/killshell.go:227–240  ·  view source on GitHub ↗

以下辅助函数预留用于未来的功能增强 当前实现使用taskManager,但这些函数提供了独立的底层操作能力 isProcessRunning 检查进程是否运行

(ctx context.Context, pid int, tc *tools.ToolContext)

Source from the content-addressed store, hash-verified

225
226// isProcessRunning 检查进程是否运行
227func (t *KillShellTool) isProcessRunning(ctx context.Context, pid int, tc *tools.ToolContext) bool {
228 if pid <= 0 {
229 return false
230 }
231
232 // 使用ps命令检查进程
233 psCmd := fmt.Sprintf("ps -p %d > /dev/null 2>&1", pid)
234 result, err := tc.Sandbox.Exec(ctx, psCmd, nil)
235 if err != nil {
236 return false
237 }
238
239 return result.Code == 0
240}
241
242// getSignalNumber 获取信号编号
243func (t *KillShellTool) getSignalNumber(signal string) int {

Callers 2

ExecuteMethod · 0.95
waitForProcessExitMethod · 0.95

Calls 1

ExecMethod · 0.65

Tested by

no test coverage detected