I’m trying to come up with a generic option to close any subprocess of BESClient that isn’t the UI or SSA. I’m not currently concerned with deeper levels of processes spawned by CMD though maybe I should be for the Exclusion option to work correctly.
I’m currently doing this to be included within an action myself, so really a modified approach to: Running a command with a timeout - #26 by JasonWalker
Since I am intending this to use in an action, I probably don’t need BESClient_ChildProcess_ExcludeList
except to be able to add things like SSA without modifying the relevance.
names of items 1 of (it, items 1 of (it, processes) whose(item 0 of it = ppid of item 1 of it) of pids of (processes "BESClient.exe" ; processes "BESClient") ) whose(name of item 1 of it is not contained by item 0 of it) of sets of ( "BESClientUI.exe" ; substrings separated by ";" of values of settings "BESClient_ChildProcess_ExcludeList" of clients )
The goal is a piece of actionscript that could be added to the end of any action with the only modifications to the action being changing wait
to run
… assuming that only 1 thing is being “run”.
What does this achieve? Is this because you need to exclude processes with a ppid that just happens to match that of the BES Client, but might have been run by something else before it?
When wanting to timeout child processes in an action context, then this seems like it would be useful:
processes whose(creation time of it > active start time of active action)
This should work more narrowly inside of an action, but more broadly outside of an action:
names of items 1 of (it, processes ) whose( creation time of item 1 of it > (active start time of active action | creation time of item 0 of it ) AND pid of item 0 of it = ppid of item 1 of it) of (processes "BESClient.exe" ; processes "BESClient")
Since this lacks any exclusions, it should return BESClientUI.exe
on windows. It seems like the creation time check is faster than the ppid check.
Q: number of creation times of processes
A: 147
T: 3.025 ms
Q: number of ppids of processes
A: 148
T: 327.941 ms
It is a good idea to use number of
to get the relative speed of each inspector, which dictates which order they should appear in a complex relevance clause for maximum performance. In this case, creation time
seems 100 times faster.
Related: https://bigfix.me/relevance/details/2999306
This is even better, and more cross platform: (which is why I’m using processes
instead of services
)
names of items 2 of (pid of it, (active start time of active action | ( if (exists properties whose(it as string starts with "creation time of <process>")) then creation time of it else start time of it ) of it), processes ) whose( creation time of item 2 of it > item 1 of it AND item 0 of it = ppid of item 2 of it) of (processes "BESClient.exe" ; processes "BESClient")
I have no idea why there is a difference between creation time of process
and start time of process
other than that they are supported on different platforms. Seems like they should be aliases of each other and available on all platforms where either is supported… which is probably a question for: @AlanM
Yet another improvement:
names of items 3 of (pid of it, (active start time of active action | ( if (exists properties whose(it as string starts with "creation time of <process>")) then creation time of it else start time of it ) of it), set of ("BESClientUI.exe";"BESClientUI"), processes ) whose( creation time of item 3 of it > item 1 of it AND name of item 3 of it is not contained by item 2 of it AND item 0 of it = ppid of item 3 of it) of (processes "BESClient.exe" ; processes "BESClient")
Note: active start time of active action
should always work on all platforms in an action context, while neither creation time of process
and start time of process
will work on Mac currently.