mirror of
https://github.com/hymkor/lispect.git
synced 2026-09-02 23:27:39 -04:00
Implement (wait PID)
This commit is contained in:
@@ -214,3 +214,18 @@ func (g *Global) setenv(ctx context.Context, w *gmnlisp.World, __key, __val gmnl
|
|||||||
|
|
||||||
return gmnlisp.Null, os.Setenv(key, val)
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ func mains(args []string) error {
|
|||||||
gmnlisp.NewSymbol("expect"): gmnlisp.SpecialF(g.expect),
|
gmnlisp.NewSymbol("expect"): gmnlisp.SpecialF(g.expect),
|
||||||
gmnlisp.NewSymbol("getenv"): gmnlisp.Function1(g.getenv),
|
gmnlisp.NewSymbol("getenv"): gmnlisp.Function1(g.getenv),
|
||||||
gmnlisp.NewSymbol("setenv"): gmnlisp.Function2(g.setenv),
|
gmnlisp.NewSymbol("setenv"): gmnlisp.Function2(g.setenv),
|
||||||
|
gmnlisp.NewSymbol("wait"): gmnlisp.Function1(g.wait),
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(args) <= 0 {
|
if len(args) <= 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user