diff --git a/uci/engine.go b/uci/engine.go index 31344c5..f093f9f 100644 --- a/uci/engine.go +++ b/uci/engine.go @@ -57,12 +57,19 @@ func New(path string, opts ...func(e *Engine)) (*Engine, error) { for _, opt := range opts { opt(e) } - go func() { - _ = e.cmd.Run() - }() + err = e.cmd.Start() + if err != nil { + return nil, fmt.Errorf("uci: failed to start executable %s: %w", path, err) + } + go e.cmd.Wait() + return e, nil } +func (e *Engine) Getpid() int { + return e.cmd.Process.Pid +} + // ID returns the id values returned from the most recent CmdUCI invocation. It includes // key value data such as the following: // id name Stockfish 12