2026-03-30 15:48:21 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package agentic
|
|
|
|
|
|
|
|
|
|
import (
|
2026-03-30 16:01:32 +00:00
|
|
|
"context"
|
2026-03-30 15:48:21 +00:00
|
|
|
|
|
|
|
|
core "dappco.re/go/core"
|
2026-03-30 16:01:32 +00:00
|
|
|
"dappco.re/go/core/process"
|
2026-03-30 15:48:21 +00:00
|
|
|
)
|
|
|
|
|
|
2026-03-30 16:01:32 +00:00
|
|
|
func ExampleProcessAlive() {
|
|
|
|
|
r := testCore.Process().Start(context.Background(), core.NewOptions(
|
|
|
|
|
core.Option{Key: "command", Value: "sleep"},
|
|
|
|
|
core.Option{Key: "args", Value: []string{"1"}},
|
|
|
|
|
core.Option{Key: "detach", Value: true},
|
|
|
|
|
))
|
|
|
|
|
if !r.OK {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
proc := r.Value.(*process.Process)
|
|
|
|
|
defer proc.Kill()
|
|
|
|
|
|
|
|
|
|
core.Println(ProcessAlive(testCore, proc.ID, proc.Info().PID))
|
2026-03-30 15:48:21 +00:00
|
|
|
// Output: true
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 16:01:32 +00:00
|
|
|
func ExampleProcessTerminate() {
|
|
|
|
|
r := testCore.Process().Start(context.Background(), core.NewOptions(
|
|
|
|
|
core.Option{Key: "command", Value: "sleep"},
|
|
|
|
|
core.Option{Key: "args", Value: []string{"1"}},
|
|
|
|
|
core.Option{Key: "detach", Value: true},
|
|
|
|
|
))
|
|
|
|
|
if !r.OK {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
proc := r.Value.(*process.Process)
|
|
|
|
|
defer proc.Kill()
|
|
|
|
|
core.Println(ProcessTerminate(testCore, proc.ID, proc.Info().PID))
|
|
|
|
|
// Output: true
|
2026-03-30 15:48:21 +00:00
|
|
|
}
|