Screen recording permission ignored

Hi all,

I have Chrome extension which executes native binary using native messaging. Native binary (named nmhost) is programmed in C++/Qt. nmhost executes screencapture command to take screenshots. macOS asks user to grant screen recording permission. And here is the problem: granted permissions are simply ignored. So, no matter how many times user checks/unchecks permission in security&privacy - nmhost can not take screenshot and always asks for permission.

So, why does this happen and how to fix it?

BTW, I've found workaround for this: if nmhost is called by shell script wrapper, then macOS says that sh wants to take screenshot, user can allow it, and then it works properly. But it will be nice to know how to fix this without wrapper.
Screen recording permission ignored
 
 
Q