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

Expose proper PID on windows and clean up process handle #49

Merged
merged 5 commits into from
Mar 13, 2017

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Mar 12, 2017

Fixes #45

@rprichard a quick review of the handle clean up would be greatly appreciated 😃

@Tyriar Tyriar added this to the 0.6.3 milestone Mar 12, 2017
@Tyriar Tyriar self-assigned this Mar 12, 2017
Copy link
Contributor

@rprichard rprichard left a comment

Choose a reason for hiding this comment

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

I think your changes make sense.

I noticed that the code was adding winpty_t* pointers to the global ptyHandles vector, but the pointers are never removed. I think that can cause a crash, because remove_pipe_handle will invalidate the winpty pointer by calling winpty_free, but then the pointer is still in the vector. To fix it, you'd want to add something like this to remove_pipe_handle:

ptyHandles.erase(ptyHandles.begin() + i)

You could also remove the winpty_s struct (and the winpty_s::winpty_s() constructor). That code isn't being used at all, and I think it's harmless, but it's a bit of a distraction. There's a real winpty_s inside the winpty DLL, and it has a different definition.

src/win/pty.cc Outdated
{
return Nan::ThrowError("Usage: pty.kill(pid)");
}

int handle = info[0]->Int32Value();
HANDLE innerPidHandle = (HANDLE)info[0]->Int32Value();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be info[1]->Int32Value?

src/win/pty.cc Outdated
|| !info[0]->IsNumber()) // pid
if (info.Length() != 2
|| !info[0]->IsNumber() // pid
|| !info[1]->IsNumber()) // innerPidHandle
{
return Nan::ThrowError("Usage: pty.kill(pid)");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I suppose this usage string is now incorrect -- i.e. it should be something like pty.kill(pid, innerPidHandle)

@Tyriar
Copy link
Member Author

Tyriar commented Mar 13, 2017

@rprichard great feedback thanks, I made the changes and they seem to compile and work fine.

@Tyriar Tyriar merged commit 09f3159 into master Mar 13, 2017
@Tyriar Tyriar deleted the 45_expose_pid_cleanup_handle branch March 13, 2017 20:37
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.

2 participants