Merged revisions 62129,62131,62133 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r62129 | trent.nelson | 2008-04-03 19:27:06 +0100 (Thu, 03 Apr 2008) | 16 lines

  Reimplement kill_python.  The existing version had a number of flaws, namely, it didn't work for x64 and it wasn't precise about which python_d.exe it was killing -- it just killed the first one it came across that happened to have 'pcbuild\python_d.exe' or 'build\python_d.exe' in it's path.  The new version has been rewritten from the ground up and now lives in PCbuild, instead of Tools\buildbot, and it has also been incorporated into the Visual Studio solution (pcbuild.sln) as 'kill_python'.  The solution has also been altered such that kill_python is called where necessary in the build process in order to prevent any linking errors due to open file locks.  In lieu of this, all of the existing bits and pieces in Tools\buildbot that called out to kill_python at various points have also been removed as they are now obsolete.  Tested on both Win32 and x64.

  Change set (included to improve usefulness of svnmerge log entry):
  M      PCbuild\pythoncore.vcproj
  M      PCbuild\pcbuild.sln
  M      PCbuild\release.vsprops
  A      PCbuild\kill_python.vcproj
  M      PCbuild\debug.vsprops
  A      PCbuild\kill_python.c
  D      Tools\buildbot\kill_python.bat
  D      Tools\buildbot\kill_python.mak
  M      Tools\buildbot\build.bat
  D      Tools\buildbot\Makefile
  M      Tools\buildbot\build-amd64.bat
  M      Tools\buildbot\buildmsi.bat
  D      Tools\buildbot\kill_python.c
........
  r62131 | trent.nelson | 2008-04-03 19:48:53 +0100 (Thu, 03 Apr 2008) | 1 line

  Add the correct OutputFile values for debug builds.  Fixes r62129's commit.
........
  r62133 | trent.nelson | 2008-04-03 21:00:08 +0100 (Thu, 03 Apr 2008) | 1 line

  Make kill_python a little more forgiving if it can't obtain a snapshot of module information for a given python[_d].exe process.  Failing here was too pessimistic; the python[_d].exe process may be owned by another user, which is the case in some buildbot environments.
........
This commit is contained in:
Trent Nelson 2008-04-03 20:47:30 +00:00
parent f12e541174
commit 61828c725a
13 changed files with 519 additions and 99 deletions

View file

@ -1,6 +0,0 @@
all: kill_python.exe
./kill_python.exe
kill_python.exe: kill_python.c
gcc -o kill_python.exe kill_python.c -lpsapi

View file

@ -1,6 +1,5 @@
@rem Used by the buildbot "compile" step.
cmd /c Tools\buildbot\external-amd64.bat
call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
REM cmd /q/c Tools\buildbot\kill_python.bat
cmd /c Tools\buildbot\clean-amd64.bat
vcbuild PCbuild\pcbuild.sln "Debug|x64"

View file

@ -1,7 +1,6 @@
@rem Used by the buildbot "compile" step.
cmd /c Tools\buildbot\external.bat
call "%VS90COMNTOOLS%vsvars32.bat"
cmd /q/c Tools\buildbot\kill_python.bat
cmd /c Tools\buildbot\clean.bat
vcbuild /useenv PCbuild\pcbuild.sln "Debug|Win32"

View file

@ -8,7 +8,6 @@ if not exist ..\db-4.4.20\build_win32\release\libdb44s.lib (
)
@rem build Python
cmd /q/c Tools\buildbot\kill_python.bat
vcbuild /useenv PCbuild\pcbuild.sln "Release|Win32"
@rem build the documentation

View file

@ -1,3 +0,0 @@
cd Tools\buildbot
nmake /C /S /f kill_python.mak
kill_python.exe

View file

@ -1,68 +0,0 @@
/* This program looks for processes which have build\PCbuild\python.exe
in their path and terminates them. */
#include <windows.h>
#include <psapi.h>
#include <stdio.h>
int main()
{
DWORD pids[1024], cbNeeded;
int i, num_processes;
if (!EnumProcesses(pids, sizeof(pids), &cbNeeded)) {
printf("EnumProcesses failed\n");
return 1;
}
num_processes = cbNeeded/sizeof(pids[0]);
for (i = 0; i < num_processes; i++) {
HANDLE hProcess;
char path[MAX_PATH];
HMODULE mods[1024];
int k, num_mods;
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION
| PROCESS_VM_READ
| PROCESS_TERMINATE ,
FALSE, pids[i]);
if (!hProcess)
/* process not accessible */
continue;
if (!EnumProcessModules(hProcess, mods, sizeof(mods), &cbNeeded)) {
/* For unknown reasons, this sometimes returns ERROR_PARTIAL_COPY;
this apparently means we are not supposed to read the process. */
if (GetLastError() == ERROR_PARTIAL_COPY) {
CloseHandle(hProcess);
continue;
}
printf("EnumProcessModules failed: %d\n", GetLastError());
return 1;
}
if (!GetModuleFileNameEx(hProcess, NULL, path, sizeof(path))) {
printf("GetProcessImageFileName failed\n");
return 1;
}
_strlwr(path);
/* printf("%s\n", path); */
/* Check if we are running a buildbot version of Python.
On Windows, this will always be a debug build from the
PCbuild directory. build\\PCbuild\\python_d.exe
On Cygwin, the pathname is similar to other Unixes.
Use \\build\\python.exe to ensure we don't match
PCbuild\\python.exe which could be a normal instance
of Python running on vanilla Windows.
*/
if ((strstr(path, "pcbuild\\python_d.exe") != NULL) ||
(strstr(path, "\\build\\python.exe") != NULL)) {
printf("Terminating %s (pid %d)\n", path, pids[i]);
if (!TerminateProcess(hProcess, 1)) {
printf("Termination failed: %d\n", GetLastError());
return 1;
}
return 0;
}
CloseHandle(hProcess);
}
}

View file

@ -1,2 +0,0 @@
kill_python.exe: kill_python.c
cl -nologo -o kill_python.exe kill_python.c psapi.lib