Getting the pid of a network extension

Yes, actual process ID: on upgrades, our network extension sometimes decides to become completely incommunicado as far as XPC is concerned -- any attempt to send an XPC message to it results in "couldn't communicate with a helper application" or similar. The only workaround I've been able to come up with is unloading and reloading the extension.

It was suggested that I try killing it. Which, great, but... how would I get it's pid? I do not at all feel comfortable launching pkill; I could get all the processes on the system and look for the name. But is there a way for the wrapping process to be able to get the pid?

But is there a way for the wrapping process to be able to get the pid?

No.

Well, if you have an XPC channel open you can get the pid of the remote peer, but that doesn’t help in this situation.

It was suggested that I try killing it.

For the purposes of investigating this issue? Or for the purposes of deploying a workaround to users?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

A work-around for the users.

I managed to get my system into quite the state testing this -- an old version of the extension stuck around, despite multiple reinstallation attempts; kill -9 did absolutely nothing to it; using systemextensionctl to uninstall it did that, but then it couldn't be re-installed. I rebooted and all was well with the system again.

Mind you, it's hard to tell how much of those issues were caused by this being a development machine, which means it is sometimes in a very questionable state. 😄

One thing I thought to try to do was to have the extension try making an XPC connection to itself, but that doesn't work, presumably due to sandboxing.

No, that was simply PEBKAC. It turns out you need to call connection.resume() when making an XPC connection.

Getting the pid of a network extension
 
 
Q