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 |
|
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 #28617 is a reply to message #28603] |
Wed, 08 September 2010 11:15 |
|
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
|
|
|
Goto Forum:
Current Time: Tue Jun 04 00:52:55 CEST 2024
Total time taken to generate the page: 0.02630 seconds
|