Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPII-2578: Make more use of the process reporter #169

Closed
wants to merge 11 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@stegru
Copy link
Member

stegru commented Mar 20, 2018

There's some overlap with processHandling and processReporter. This PR removes functions from processHandling that have been implemented in processReporter.

processHandling now (mostly) just contains process actions.

@gpii-bot

This comment has been minimized.

Copy link
Collaborator

gpii-bot commented Mar 20, 2018

@gpii-bot

This comment has been minimized.

Copy link
Collaborator

gpii-bot commented Mar 20, 2018

@gpii-bot

This comment has been minimized.

Copy link
Collaborator

gpii-bot commented Mar 20, 2018

@klown
Copy link
Contributor

klown left a comment

Looks good to me -- thanks Steve! I have a few minor suggestions.

var hProcess = windows.kernel32.OpenProcess(c.PROCESS_TERMINATE, 0, pids[n]);
var procs = processesBridge.findProcessesByCommand(filename);

if (procs) {

This comment has been minimized.

@klown

klown Mar 21, 2018

Contributor

findProcessesByCommand() always returns an array, even if it's empty. No need to check if procs is non-null

This comment has been minimized.

@stegru

stegru Mar 26, 2018

Author Member

as one would expect.

@@ -51,7 +51,8 @@ public class Startup
}
} else {
ManagementObject[] someProcesses = Array.FindAll(
processes, p => p.GetPropertyValue("Name").ToString() == input
processes,
p => string.Equals(p.GetPropertyValue("Name").ToString(), input, StringComparison.OrdinalIgnoreCase)

This comment has been minimized.

@klown

klown Mar 21, 2018

Contributor

Thanks for catching this. I had no idea that Windows processes were case insensitive. Live and learn.

This comment has been minimized.

@stegru

stegru Mar 26, 2018

Author Member

For some unknown reason, the test-window.exe process was being reported as TEST-WINDOW.EXE.

@@ -35,6 +35,11 @@ fluid.defaults("gpii.processes.windows", {
funcName: "gpii.processes.windows.getProcessList",
args: ["{arguments}.0"]
// process name or id, optional.
},
compareProcessNames: {

This comment has been minimized.

@klown

klown Mar 21, 2018

Contributor

I'm wondering if this belongs upstream in universal as part of the "gpii.processes" base grade. I don't see anything Windows specific about it. The implementation uses the standard JavaScript String.toLower() function. Is there anything OS specific here?

This comment has been minimized.

@stegru

stegru Mar 26, 2018

Author Member

I was on the fence with this.

My reason was the code isn't windows-specific, but what it does is specific. But, it does seem to be a lot of "fluff" just for a === statement - especially considering the "real" comparison is in the .csx file.

I've moved the actual checking into universal, but left the decision of ignoring the case in windows.

This comment has been minimized.

@klown

klown Mar 27, 2018

Contributor

That makes sense.

The macOS file system can be either case insensitive or case sensitive depending on how it's configured (factory setting is insensitive). I don't know about Android or iOS, but I suspect the former is sensitive and the latter is insensitive. This is an invoker that's context dependent (infusion-speak).

"Node commmand name", "node.exe", aProcInfo.command
);
});
var procInfo = processesBridge.findFirstProcessByCommand("NoDE.eXe");

This comment has been minimized.

@klown

klown Mar 21, 2018

Contributor

Love it! Someone hiccoughed typing "nOde.ExE". :-)

var exe = gpii.windows.getProcessPath(gpii.windows.getWindowProcessId(hwnd));

var proc = processesBridge.findProcessByPid(gpii.windows.getWindowProcessId(hwnd));
var exe = proc && proc.fullPath;

This comment has been minimized.

@klown

klown Mar 21, 2018

Contributor

After seeing at least two occurrences of proc && proc.fullPath, my gut says to add a getProcessPath() invoker to the base grade in universal.

This comment has been minimized.

@stegru

stegru Mar 26, 2018

Author Member

My gut agreed.

This comment has been minimized.

@klown

klown Mar 27, 2018

Contributor

Cool, I'll go give that pull request a peek.

@gpii-bot

This comment has been minimized.

Copy link
Collaborator

gpii-bot commented Mar 26, 2018

var procs = processesBridge.findProcessesByCommand(filename);

if (procs) {
for (var n = 0, len = procs.length; n < len; n++) {

This comment has been minimized.

@klown

klown Mar 27, 2018

Contributor

I should have thought of this before, but ... using an iterator like fluid.each() here would be more transparent.

@stegru

This comment has been minimized.

Copy link
Member Author

stegru commented Jun 19, 2018

Closing: This Pr is a subset of #170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.