Implement (wait PID)

This commit is contained in:
HAYAMA_Kaoru
2024-12-05 12:11:09 +09:00
parent 9d7317330e
commit 7b7e0ebccc
2 changed files with 16 additions and 0 deletions
+15
View File
@@ -214,3 +214,18 @@ func (g *Global) setenv(ctx context.Context, w *gmnlisp.World, __key, __val gmnl
return gmnlisp.Null, os.Setenv(key, val)
}
func (g *Global) wait(ctx context.Context, w *gmnlisp.World, pidNode gmnlisp.Node) (gmnlisp.Node, error) {
pidInteger, err := gmnlisp.ExpectClass[gmnlisp.Integer](ctx, w, pidNode)
if err != nil {
return nil, err
}
pid := int(pidInteger)
process, err := os.FindProcess(pid)
if err != nil {
return gmnlisp.Null, nil
}
_, err = process.Wait()
return gmnlisp.Null, err
}