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++ Library support » U++ Core » [BUG&FIX] LocalProcess can not be reused
[BUG&FIX] LocalProcess can not be reused [message #28578] Tue, 07 September 2010 21:29 Go to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi,

Jean-Paul found some unexpected behavior in the LocalProcess. It is easily reproducible:
#include <Core/Core.h>
using namespace Upp;

CONSOLE_APP_MAIN{
	String app="mousepad";
	LocalProcess p;
	p.Start(app);
	p.Kill();
	p.Start(app);
	p.Kill(); // <-- doesn't work, the app is continues running
}


Fix is simple as well. The problem is, that exit_code is not reset after killing the process. So setting it back to null in Free() is enough to get correct behavior:
void LocalProcess::Free() {
#ifdef PLATFORM_WIN32
	if(hProcess) {
		CloseHandle(hProcess);
		hProcess = NULL;
	}
	if(hOutputRead) {
		CloseHandle(hOutputRead);
		hOutputRead = NULL;
	}
	if(hInputWrite) {
		CloseHandle(hInputWrite);
		hInputWrite = NULL;
	}
#endif
#ifdef PLATFORM_POSIX
	LLOG("\nLocalProcess::Free, pid = " << (int)getpid());
	LLOG("rpipe[" << rpipe[0] << ", " << rpipe[1] << "]");
	LLOG("wpipe[" << wpipe[0] << ", " << wpipe[1] << "]");
	if(rpipe[0] >= 0) { close(rpipe[0]); rpipe[0] = -1; }
	if(rpipe[1] >= 0) { close(rpipe[1]); rpipe[1] = -1; }
	if(wpipe[0] >= 0) { close(wpipe[0]); wpipe[0] = -1; }
	if(wpipe[1] >= 0) { close(wpipe[1]); wpipe[1] = -1; }
	if(pid) waitpid(pid, 0, WNOHANG | WUNTRACED);
	pid = 0;
	output_read = false;
#endif
	exit_code = Null; // <-- Added
}


Mirek, can you apply it, please?

Best regards,
Honza
Re: [BUG&FIX] LocalProcess can not be reused [message #28599 is a reply to message #28578] Wed, 08 September 2010 09:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Applied, thank you.

Mirek
Re: [BUG&FIX] LocalProcess can not be reused [message #28603 is a reply to message #28599] Wed, 08 September 2010 10:15 Go to previous messageGo to next message
jpderyck is currently offline  jpderyck
Messages: 15
Registered: October 2008
Location: Belgium
Promising Member
Hello,
thanks for the fix!

in wich version of upp will this be available ?
I currently use the 2659-karmic-i386 on ubuntu and added the ppa:dolik-rce/upp-nightly to get latest

best regards
and congratulations for upp !
vraiment épatant !

Jean-Paul
Re: [BUG&FIX] LocalProcess can not be reused [message #28617 is a reply to message #28603] Wed, 08 September 2010 11:15 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

jpderyck wrote on Wed, 08 September 2010 10:15

Hello,
thanks for the fix!

in wich version of upp will this be available ?
I currently use the 2659-karmic-i386 on ubuntu and added the ppa:dolik-rce/upp-nightly to get latest

best regards
and congratulations for upp !
vraiment épatant !

Jean-Paul


It was committed today, at 2669, so it will be available in the upp-nightly PPA tomorrow morning, if everything goes well.

BTW: Unless you have your repositories pointed to /usr/share/upp, you might have to manually copy the sources from /usr/share/upp to you local copy in /home after the update. Sorry for inconvenience, it is design glitch which is being fixed right now.

Honza
Previous Topic: DLI doc fix
Next Topic: Write an app to start and kill another app periodically
Goto Forum:
  


Current Time: Sat Apr 27 19:02:23 CEST 2024

Total time taken to generate the page: 0.04924 seconds