How to attach process under root/different user account?


As the title said, what is the recommended way to attach a process under different user account?

On Mac OS, when I try to use python binding to attach a root process, I got a dialog saying “python is trying to take control of a root process …”. After inputing password into the dialog, I got failure:
“Problems with launching via XPC. XPC error: Connection interrupted”

For Linux scenario, our IDE runs on MacOS, while using a RPC framework talking to a IDE server on Linux devserver. This IDE server will use lldb python binding to attach target process on Linux.
Is there any good way to attach root process on Linux devserver without running IDE server under root account?

I guess I may need a UI/channel to gather user credential and elevate lldb python binding process in some way. But a bit vague in this part. Thanks for any input!