scdaemon supports DEVINFO --watch command to keep watching the device removal.
It loops forever (for the current implementation), and the only way to stop watcing is killing scdaemon.
It should work in the following way, like:
(1) It simultaneously polls device info updates and client input close.
(2) On device info update, send the information to client.
(3) On the client input close, finish the command (and finish the connection from client).
But it is not only scdaemon, but also gpg-agent should behave like that, because gpgme uses gpg-agent to access scdaemon.
That is:
(1) gpg-agent (for DEVINFO command) should simultaneously polls on (a) scdaemon's output and (b) client input close.
(2) On the scdaemon output, send the information to client.
(3) On the client input close, finish the command and finish the connection to scdaemon, and finish the connection from client).