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++ Library : Other (not classified elsewhere) » Process Class wrapper for pipes in windows/linux
Process Class wrapper for pipes in windows/linux [message #11162] Fri, 24 August 2007 15:56 Go to next message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
does something like this already exist in ultimate++? If not, will it be added some time?

Some class, which wraps redirecting of streams between pipes stdout/int, sterr, creating your won streams to communicate between processes using pipes..

(I am mainly talking about a wrapper for the windows-api-function _popen(...), and the posix standart functions popen(...)

Greetings, Tom
Re: Process Class wrapper for pipes in windows/linux [message #11171 is a reply to message #11162] Sat, 25 August 2007 10:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Search for "SlaveProcess".

Also, look into ide sources, Console.cpp or GDB interface.

Mirek
Re: Process Class wrapper for pipes in windows/linux [message #11193 is a reply to message #11162] Sun, 26 August 2007 17:53 Go to previous messageGo to next message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
thx... i have looked through the sources.. but i still have no clue how to use SlaveProcess... Somehow it gives me An error all the time, becuase Slave process is pure virtual, although iI am using "StartLocalProcess" and such stuff... I must admit: I have no clue, how SlaveProcess works ^^.

What would i need to do to achieve something like this with UPP:


FILE pipe=_popen("gnuplot.exe","w"); //start process

fprintf(pipe,"plot sin(x) \n"); //execute command in remote process
fflush(pipe);

_pclose(pipe);


greetings, Tom

[Updated on: Sun, 26 August 2007 17:53]

Report message to a moderator

Re: Process Class wrapper for pipes in windows/linux [message #11198 is a reply to message #11193] Sun, 26 August 2007 19:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Should be something like:

One<SlaveProcess> p = StartLocalProcess("gnuplot w");
if(p) // started OK
    p.Write("plot sin(x)\n");


Mirek
Re: Process Class wrapper for pipes in windows/linux [message #11201 is a reply to message #11198] Mon, 27 August 2007 13:14 Go to previous messageGo to next message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
ahh i figured what my problem was: I #included the <web/sproc.h>-file and not the <web/web.h>. For some Reason the compiler had problems linking all that stuff...

Here is my code so far:
One<SlaveProcess> pipe;
pipe=StartLocalProcess("pgnuplot");
	
if(pipe){
   pipe->Write("plot sin(x)\n");

   cout<<"running...\n";
   String s;
   Sleep(10000);	
   pipe->Kill();
   cout<<"gnuplot returned: "<<pipe->GetExitCode();
}//*/


I got the problem, that In this code "pipe" is NEVER invalid, as long as I have pgnuplot as starting command. Even if there appears a problem with starting pgnuplot for example, if I use invalid options and similar stuff.

Second Problem is, that for some reason I can not use the Kill()-Command. I am just not able to finish gnuplot when I started it...

Any idea on this?


Greetings, Tom...
Re: Process Class wrapper for pipes in windows/linux [message #11202 is a reply to message #11201] Mon, 27 August 2007 15:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Maybe a PATH problem?

Mirek
Re: Process Class wrapper for pipes in windows/linux [message #11204 is a reply to message #11202] Mon, 27 August 2007 16:14 Go to previous messageGo to next message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
hmmm.... I made some further research and it seems that the Slaveprocess functions somehow interfere with the Sleep() function of U++...

All i can say is: as soon as I avoid using the Sleep function everything works just as expected...

Form the moment on, when I call the sleep function, the "pipe" object somehow gets disconnected from the process it owns, and I can not use the write, kill, read or whatever command then anymore....


greetings, Tom

[Updated on: Mon, 27 August 2007 17:15]

Report message to a moderator

Re: Process Class wrapper for pipes in windows/linux [message #11245 is a reply to message #11204] Tue, 28 August 2007 19:00 Go to previous messageGo to next message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
luzr is this a bug or something that you`d expect? Or Am I doing something wrong?

Greetings, Tom
Re: Process Class wrapper for pipes in windows/linux [message #11246 is a reply to message #11245] Tue, 28 August 2007 19:07 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, is not it actually possible that process is finished while sleeping? (OTOH, in that case, it should still be kept as zombie).

All I can say is that SlaveProcess is extensively used in theide and (obviously) it seems to work.

Mirek
Previous Topic: Add capability to Log into Windows console
Next Topic: Bug in AddColumn of ArrayCtrl
Goto Forum:
  


Current Time: Sat Apr 20 00:38:34 CEST 2024

Total time taken to generate the page: 0.04370 seconds