We are pixie.io ran into exact problem, we fixed that by parsing the braces, ugly but seems working
https://github.com/pixie-io/pixie/blob/bd82bb48ef4da7d6b05f2...
https://github.com/pixie-io/pixie/blob/bd82bb48ef4da7d6b05f2...
https://gitlab.com/psmisc/psmisc/-/blob/master/src/pstree.c#...
But what if comm contains newlines?