In this command, N is a decimal number. When you receive the command, reply by sending the string pong N, where N is the same number you received. Important: You must not reply to a "ping" command until you have finished executing all commands that you received before it. Pondering does not count; if you receive a ping while pondering, you should reply immediately and continue pondering. Because of the way xboard uses the ping command, if you implement the other commands in this protocol, you should never see a "ping" command when it is your move; however, if you do, you must not send the "pong" reply to xboard until after you send your move. For example, xboard may send "?" immediately followed by "ping". If you implement the "?" command, you will have moved by the time you see the subsequent ping command. Similarly, xboard may send a sequence like "force", "new", "ping". You must not send the pong response until after you have finished executing the "new" command and are ready for the new game to start.
I have been interpreting this as meaning ping during ponder always should be immediately responded to. However, I am encountering an issue when the UI sends a "result" command, due to an adjudicated draw for example. Here (the UI is cutechess-cli) I see "force", "result" and then "ping" sent to the engine. The engine currently sends "pong" right away if it was pondering. However, it appears this is incorrect: what happens is it then gets a bunch of commands to start a new game, most of which arrive while the ponder search is still happening (because "result" began the process of terminating the search but it is not terminated yet). And it really isn't ready to process those. So it seems to me it should terminate the search when force and/or result are received, and then send the "pong" command after search termination. So in other words, "reply immediately and continue pondering" doesn't apply if you have already received a ponder-terminating command prior to "ping."