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 » Sys command truncates captured console output
Sys command truncates captured console output [message #48530] Sat, 15 July 2017 12:11 Go to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi

I am running sed script on a 1 Mb file from UPP code using Sys(cmd,output) . Ubuntu 16.04. UPP ver 10205
It captures complete output of sed

Recently I changed to UPP ver 11213
Now my Captured output of Sys("SED command",output); is truncated to 2Kb.

I found following change in "LocalProcess.cpp" from version 10205 to 11213.

Ver 10205 Line 513 while((sv = select(pipe[0]+1, set, NULL, NULL, &tval)) > 0)

Ver 11213 Line 513 if ((sv = select(pipe[0]+1, set, NULL, NULL, &tval)) > 0)

Changed "if" back to "while" is working fine for me.

File Core/LocalProcess.cpp working code
		while((sv = select(pipe[0]+1, set, NULL, NULL, &tval)) > 0) {
			LLOG("Read() -> select");
			char buffer[1024];
			int done = read(pipe[0], buffer, sizeof(buffer));
			LLOG("Read(), read -> " << done);
			if(done > 0)
				res[wp].Cat(buffer, done);
			else if (done == 0) {
				close(pipe[0]);
				pipe[0] = -1;
			}
		}


Warm Regards

Deepak
Re: Sys command truncates captured console output [message #48531 is a reply to message #48530] Sat, 15 July 2017 13:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ops.

Can you test this fix, please?

int LocalProcess::Finish(String& out)
{
	out.Clear();
	while(IsRunning()) {
		out.Cat(Get());
		Sleep(1); // p.Wait would be much better here!
	}
	for(;;) {
		String h = Get();
		if(h.IsVoid())
			break;
		out.Cat(h);
	}
	return GetExitCode();
}

Re: Sys command truncates captured console output [message #48532 is a reply to message #48530] Sat, 15 July 2017 13:40 Go to previous message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Mirek,

Thanks for your quick response.

I reverted while to if in function bool LocalProcess::Read2(String& reso, String& rese)

Made changes in int LocalProcess::Finish(String& out) as per your message.

It is working correctly as expected.


Warm Regards

Deepak
Previous Topic: How to distribute some parts of Core in another library?
Next Topic: how to open Trace in U++ core?
Goto Forum:
  


Current Time: Thu Mar 28 12:55:30 CET 2024

Total time taken to generate the page: 0.01638 seconds