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

Prevent TerminateProcess(0) #290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sc2api/sc2_coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ CoordinatorImp::CoordinatorImp() :

CoordinatorImp::~CoordinatorImp() {
for (auto& p : process_settings_.process_info) {
TerminateProcess(p.process_id);
if (p.process_id > 0) {
TerminateProcess(p.process_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, you should put if (p.process_id > 0) inside TerminateProcess?

Copy link
Author

Choose a reason for hiding this comment

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

True. I am trying to think of a case where you would want to use TerminateProcess(0) and I can't find any. So I would add this if... here instead and return false.

But @N00byEdge reacted with a thumps down. So maybe there is a reason to keep it there?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you really want to prevent such behaviour, it should be placed inside TerminateProcess.
To me 0 looks like not properly initialised object. However, there could be some logic around it or simply a error in the code (i.e. the id is not set when needed) but we don't see it because of the current behaviour of TerminateProcess.

Is it covered by unit tests somehow?

@KevinCalderone could you please shed the light on this implementation?

}
}
}

Expand Down