Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#15356 closed defect (fixed)

wxKill does not kill cmd process

Reported by: steelwil Owned by:
Priority: low Milestone:
Component: documentation Version: 2.9.5
Keywords: wxKill Cc:
Blocked By: Blocking:
Patch: no

Description

On Windows 7 64 bit, running a 32 bit app: wxKill fails to kill a console application.

The program performs the following steps.

  1. create a cmd process - the 32bit cmd is correctly created.
  1. kill the above created process - this however fails, with wxKILL_ERROR.

wxProcess::Kill has the same behavior.

A native 64 bit cmd has the same issue.

Here is the example code:

#define _CRT_SECURE_NO_WARNINGS
#include <wx/utils.h> 
#include <wx/log.h> 

int _tmain(int argc, _TCHAR* argv[])
{
	long pid = wxExecute("cmd");
	wxLogMessage("PID:%d", pid);
	wxKillError error;
	wxKill(pid, wxSIGTERM, &error);
	wxLogMessage("Error:%d", error);
	return 0;
}

Change History (7)

comment:1 Changed 17 months ago by vadz

  • Component changed from wxMSW to documentation
  • Priority changed from normal to low
  • Status changed from new to confirmed

You need to use wxSIGKILL for the processes without windows under Windows. This should probably be mentioned in the documentation...

comment:2 follow-up: Changed 17 months ago by steelwil

I was looking at the source code. The documentation is incorrect it works if you use wxSIGKILL!

The following in the docs is therefore false:
wxSIGNONE, wxSIGKILL and wxSIGTERM have the same meaning under both Unix and Windows but all the other signals are equivalent to wxSIGTERM under Windows.

Maybe the default for windows should rather be wxSIGKILL.

This ticket can be closed once the docs are fixed.

comment:3 Changed 17 months ago by steelwil

Thanks vadz

comment:4 Changed 17 months ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [74587]) Document wxKill(wxSIGTERM) reliance on having an open window in wxMSW.

wxKill(wxSIGTERM) doesn't work if the child process has no open windows as it
doesn't have anything to post the WM_QUIT message to.

Document this and point out that wxKill(wxSIGKILL) still works in this case.

Closes #15356.

comment:5 in reply to: ↑ 2 Changed 17 months ago by vadz

Replying to steelwil:

The following in the docs is therefore false:
wxSIGNONE, wxSIGKILL and wxSIGTERM have the same meaning under both Unix and Windows but all the other signals are equivalent to wxSIGTERM under Windows.

I don't think this is false, why?

Maybe the default for windows should rather be wxSIGKILL.

No, this would be really dangerous.

comment:6 Changed 17 months ago by steelwil

You are right, just a bit confusing for me, I read it this way:

wxSIGNONE = wxSIGKILL = wxSIGTERM for both Unix and Windows
Everything else for windows = wxSIGTERM hence everything is wxSIGTERM for windows.

Maybe it should be reworded.

comment:7 Changed 17 months ago by steelwil

Something like:

For windows wxSIGNONE, wxSIGKILL and wxSIGTERM are recognized, all other signals are equivalent to wxSIGTERM.

Note: See TracTickets for help on using tickets.