Created
May 2, 2016 16:30
-
-
Save rsmudge/6237e6923c181c0bc7e57fd6288dd1db to your computer and use it in GitHub Desktop.
Get PID of Any Process
This file contains 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
# getexplorerpid($bid, &callback); | |
sub getanypid { | |
bps($1, lambda({ | |
local('$pid $name $entry'); | |
foreach $entry (split("\n", $2)) { | |
($name, $pid) = split("\\s+", $entry); | |
if ($name eq $proc) { | |
# $1 is our Beacon ID, $pid is the PID of $proc | |
[$callback: $1, $proc, $pid]; | |
} | |
} | |
}, $proc => $2, $callback => $3)); | |
} | |
# example to use this... | |
alias getpid { | |
getanypid($1, $2, { | |
blog($1, "The PID of $2 is: $3"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment