redirect output to memory

Reply

Join Date: Nov 2008
Posts: 2
Reputation: BITMAN2124 is an unknown quantity at this point 
Solved Threads: 0
BITMAN2124 BITMAN2124 is offline Offline
Newbie Poster

redirect output to memory

 
0
  #1
Nov 11th, 2008
I want redirect output console program to memory. It can be specified memory buffer, or buffer that I can gert ptr to later. I need to specifiy input and output of program and can do this with tmp file+redirect I/O, but that expensive operations+invloves tmp files. I know redirect output to socket
  1. startinfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
  2. startinfo.hStdInput = sockfd;
  3. startinfo.hStdOutput = sockfd;
  4. startinfo.hStdError = sockfd;
  5. CreateProcess(0, "cmd.exe", NULL, NULL, TRUE, DETACHED_PROCESS, 0, 0, &startinfo, &pinfo);
How do I redirect to memory?
also would like redirect input+err if possible
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,568
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 196
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

Re: redirect output to memory

 
0
  #2
Nov 12th, 2008
From when I programmed in C, I remember that output stream redirection is done by


a.out > filename.txt
or a.out < filename.txt

I don't remember which. One is input redirection, the other is output. I think the first is output.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: redirect output to memory

 
0
  #3
Nov 12th, 2008
Originally Posted by BestJewSinceJC View Post
From when I programmed in C, I remember that output stream redirection is done by


a.out > filename.txt
or a.out < filename.txt

I don't remember which. One is input redirection, the other is output. I think the first is output.
1) Yes, the first one is output
2) How does outputting to a file get the data into memory?

It's not enough to see one word (redirection) and come up with an answer, you must read the entire problem and understand the question before attempting to answer (redirection to memory)

BITMAN, AFAIK, there is no way to redirect to memory. And even if you could, what good would it do? Once the program is finished, the memory is gone -- so the output no longer exists. But, even if the program continues to run keeping the memory active, another program cannot access it because the memory of one program is not accessible by another program.

There is a concept called shared memory that you might look into, but you still have the problem of redirection.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 2
Reputation: BITMAN2124 is an unknown quantity at this point 
Solved Threads: 0
BITMAN2124 BITMAN2124 is offline Offline
Newbie Poster

Re: redirect output to memory

 
0
  #4
Nov 12th, 2008
I already know about redirect from cmd line, not asking that. I want redirect to memory in CreateProcess call. In code sample all i/o from cmd.exe redirected to socket, which is connect to server, so server control all i/o. in my code, I want redirect to shared memory, so after I call CreateProcess and process exits I get output of program in buffer.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC