No, that is exactly the point. The GUI cannot know that. It probably sends "stop\nucinewgame\nposition FEN\ngo infinite\n" in a single print statement, and even if it didn't, because it has the CPU's attention and the engine (or at least its input thread) is stalled waiting for input and first has to conquer a CPU time slice, even if it used separate write calls it would already have finished writing them all to the pipe before the engine even sees the second 'stop', let alone before it sends the 'bestmove 0000' reply to it. So the GUI will receive the 'bestmove' after having sent the "go infinite", and it has no other choice than to believe it was a reply to it.Ferdy wrote:If the GUI received the second bestmove 0000, it should have ignored this move, because the GUI knew that it was just testing the engine using the second stop command.
You cannot have a GUI wait after receiving a 'bestmove' it is expecting, based on "let's see if the engine prints some more, so we can take the last".
I agree that it is silly to send a second 'stop', but it is not forbidden. But sending spurious 'bestmove' commands is a sure way to wreck things. There are also legitimate uses of 'stop' that could lead it to arrive after the engine already stopped searching and sent 'bestmove'.