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

Conversation

Archiatrus
Copy link

In a proxy setting the process_id usually referring to the game instances is default initialized to 0. On Linux based systems, during the destruction of the sc2::coordinator, TerminateProcess(0) will kill all processes within the bot's processing group, including the bot itself. This is probably not intended behavior and can have unwanted side effects.

In a proxy setting the process_id usually referring to the game instances is default initialized to 0. On Linux based systems `TerminateProcess(0)` will kill all processes within the bot's processing group, including the bot itself.
@@ -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?

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