Search code examples
c++rpc

C++: stop RPC service


from my C++ source, I am starting an RPC service calling svc_run(). Everything looks just fine and I can see my service running if I type rpcinfo -p in my terminal.

Now I am working on a "cleanup" function which should stop this service and remove it from the rpcinfo -p list.

How can I do that? At the moment I am only able to stop it using sudo rpcinfo -d program version in my terminal. How can I do this from my source file?

Thanks.


Solution

  • After some time, I found out how to do this. Actually I faced some unexpected difficulties. The standard way to do this would be to use this:

    svc_unregister(PROGID, VERSION)
    

    but somehow, it did not work for me. After lots of trial and some online help (http://www.spinics.net/lists/linux-nfs/msg05619.html) I was able to delete the RPC service calling:

    pmap_unset(PROGID, VERSION);
    

    Hope this will help :)