Created
December 13, 2022 17:24
-
-
Save nikolay-n/8efae55fa187f5caecbde044fa2f631b to your computer and use it in GitHub Desktop.
xpc pid path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dump = `launchctl dumpstate`; | |
%services = (); | |
%endpoints = (); | |
$service = ""; | |
$current_service = ""; | |
$endpoints_block = 0; | |
for(split("\n", $dump)){ | |
$service = $1 if /^([^\s]+)\s=/; | |
if ($service and ($service ne $current_service)){ | |
$current_service = $service; | |
$services{$service} = {}; | |
} | |
$services{$current_service}->{pid} = $1 if /^\s+pid = (\d+)/; | |
$services{$current_service}->{program} = $1 if /^\s+program = (.+)/; | |
if ($endpoints_block){ | |
$endpoints{$1} = $services{$current_service} if (/^\t\t"([^"]+)" = /); | |
$endpoints_block = 0 if /^ \}/; | |
}elsif(/endpoints =/){ | |
$endpoints_block = 1; | |
} | |
} | |
$endpoint = shift(); | |
print "xpc service: $endpoint\n"; | |
print "pid: " .$endpoints{$endpoint}->{pid} . "\n" ; | |
print "path:" . $endpoints{$endpoint}->{program} . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: perl xpc_info.pl com.apple.tccd.system
output: