diff --git a/uci/engine.go b/uci/engine.go index 2008059..1d8ad2e 100644 --- a/uci/engine.go +++ b/uci/engine.go @@ -55,10 +55,18 @@ func New(path string, opts ...func(e *Engine)) (*Engine, error) { for _, opt := range opts { opt(e) } - go 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