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

Fix detached process issue for Windows. #43

Merged
merged 2 commits into from
Jun 16, 2020
Merged

Fix detached process issue for Windows. #43

merged 2 commits into from
Jun 16, 2020

Conversation

trooper2013
Copy link
Contributor

Disallows detaching of spawned child process on Windows. Fixes parsing of port number from the emu-launch-params.txt. CC: @brandonpage

Copy link

@brandonpage brandonpage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// NOTE: detaching a process in windows seems to detach the streams. Prevent spawn from detaching when
// used in Windows OS for special handling of some commands (adb).
private static spawnChildDetachedIfNeeded(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I don't feel like we really need to describe the "detached" part within the method signature itself. The code is pretty self-explanatory on that front. I'd vote for simply spawnChild().

// -port
// 5572
adjustedPort = this.DEFAULT_ADB_CONSOLE_PORT;
const portString = '-port';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: can we rename this to portArgumentString? I find in analyzing the code that I'm otherwise expecting this to be a string representation of the port number.

const portString = '-port';
const portStringIndx = data.indexOf(portString);
if (portStringIndx > -1) {
const portIndx = data.indexOf(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels fragile. It feels like we're shoe-horned into searching for the index of a particular numeric string because of the way we're parsing the file. Given that the structure of emu-launch-params.txt is line-by-line, a more intuitive parsing approach to me is to actually parse the file line by line too, rather than by "search" (as it were).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can address those when we tackle #8, I suppose.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised to find this, but iteration/looping is actually more performant than indexOf. https://medium.com/@mrashes2/indexof-vs-for-loop-6a9f7bd5c646

@trooper2013 trooper2013 merged commit 61afa15 into forcedotcom:dev Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants