Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » I keep getting the same "cannot open exe for writing" error...
Re: I keep getting the same "cannot open exe for writing" error... [message #50897 is a reply to message #50821] Sun, 13 January 2019 01:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2948
Registered: August 2008
Veteran
Tired of this, I added TerminateChildProcesses() just before TerminateProcess().
One week, no problem Smile


Best regards
Iñaki
Re: I keep getting the same "cannot open exe for writing" error... [message #50901 is a reply to message #50897] Sun, 13 January 2019 19:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11844
Registered: November 2005
Ultimate Member
koldo wrote on Sun, 13 January 2019 01:02
Tired of this, I added TerminateChildProcesses() just before TerminateProcess().
One week, no problem Smile


Just be warned that we had this solved many times, with "one week no problem" Smile

Mirek
Re: I keep getting the same "cannot open exe for writing" error... [message #50914 is a reply to message #50901] Mon, 14 January 2019 11:31 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 36
Registered: November 2018
Location: Germany
Member
Now, if it happens only once a week this should not be a problem. Smile

When I had the problem, it happened again and again.
I debugged simple programs without child processes.
And after the latest modification (DebugProcessStop) I had not a single problem and I did heavy repeated testing and I tried to provoke the problem.
It did not happen again here.

All the best, and happy new year!
Re: I keep getting the same "cannot open exe for writing" error... [message #50918 is a reply to message #50914] Mon, 14 January 2019 11:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11844
Registered: November 2005
Ultimate Member
peterh wrote on Mon, 14 January 2019 11:31
Now, if it happens only once a week this should not be a problem. Smile

When I had the problem, it happened again and again.
I debugged simple programs without child processes.
And after the latest modification (DebugProcessStop) I had not a single problem and I did heavy repeated testing and I tried to provoke the problem.
It did not happen again here.

All the best, and happy new year!


Well, would it be possible to came to consensus what the code should look like? I might have got lost, is trunk ok? Perhaps it does not contain koldo's addition, right? Can you post it here so that I add it to trunk?

Mirek
Re: I keep getting the same "cannot open exe for writing" error... [message #50947 is a reply to message #50914] Mon, 14 January 2019 22:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2948
Registered: August 2008
Veteran
peterh wrote on Mon, 14 January 2019 11:31
Now, if it happens only once a week this should not be a problem. Smile

When I had the problem, it happened again and again.
I debugged simple programs without child processes.
And after the latest modification (DebugProcessStop) I had not a single problem and I did heavy repeated testing and I tried to provoke the problem.
It did not happen again here.
Yes I agree.

Without changes you have to close TheIDE many times every day.

I do not know if the code I use is the best, as I do not know the root cause of the problem.
However, you should remember that TerminateProcess() does not terminate child process, so I call TerminateChildProcesses(hProcessId, 0); just before.
It uses dwProcessId from pdb.cpp, line 117:

	hProcess = pi.hProcess;
	hProcessId = pi.dwProcessId; // Added
	mainThread = pi.hThread;
	mainThreadId = pi.dwThreadId;

and TerminateChildProcesses() is implemented like this:

#include <TlHelp32.h>

Vector<DWORD> GetChildProcessList(DWORD processId) {
	Vector<DWORD> child, all, parents;
	
	HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	if (hSnap == INVALID_HANDLE_VALUE) 
		return child;
	
	PROCESSENTRY32 proc;
	proc.dwSize = sizeof(proc);
	
	if (!Process32First(hSnap, &proc)) {
		CloseHandle(hSnap);	
		return child;
	}
	
	do {
		all << proc.th32ProcessID;
		parents << proc.th32ParentProcessID;
    } while(Process32Next(hSnap, &proc));
	
	CloseHandle(hSnap);
	
	child << processId;
	int init = 0;
	while (true) {
		int count = child.GetCount();
		if (init >= count)
			break;
		for (int cid = init; cid < count; ++cid) {
			for (int i = 0; i < all.GetCount(); ++i) {
				if (parents[i] == child[cid])
					child << all[i];
			}
		}
		init = count;
	}
	child.Remove(0);
	return child;	
}

void TerminateChildProcesses(DWORD dwProcessId, UINT uExitCode) {
	Vector<DWORD> children = GetChildProcessList(dwProcessId);
	for (int i = 0; i < children.GetCount(); ++i) {
		HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, children[i]);
		TerminateProcess(hProcess, uExitCode);
		CloseHandle(hProcess);
	}
}


Best regards
Iñaki
Re: I keep getting the same "cannot open exe for writing" error... [message #51072 is a reply to message #50947] Sat, 19 January 2019 17:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2948
Registered: August 2008
Veteran
One week, no problem :)
Other week, no problem Smile


Best regards
Iñaki
Re: I keep getting the same "cannot open exe for writing" error... [message #51073 is a reply to message #51072] Sat, 19 January 2019 19:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11844
Registered: November 2005
Ultimate Member
Can you please check that Pdb.cpp in the trunk is now "the best known variant"?

Mirek
Re: I keep getting the same "cannot open exe for writing" error... [message #51076 is a reply to message #51073] Sun, 20 January 2019 14:52 Go to previous message
koldo is currently offline  koldo
Messages: 2948
Registered: August 2008
Veteran
Hi Mirek

The code proposed is set over last pdb.cpp version, adding the new function TerminateChildProcesses() before TerminateProcess(), as TerminateProcess() does not stop children processes.

Anyway, here I enclose you the patch files.
  • Attachment: pdb_patch.7z
    (Size: 1.05KB, Downloaded 6 times)


Best regards
Iñaki
Previous Topic: error: expected unqualified-id before '=' token
Next Topic: clang or MinGW
Goto Forum:
  


Current Time: Thu Apr 25 10:30:57 CEST 2019

Total time taken to generate the page: 0.01616 seconds