| | |
redirect output to memory
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
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
How do I redirect to memory?
also would like redirect input+err if possible
C Syntax (Toggle Plain Text)
startinfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; startinfo.hStdInput = sockfd; startinfo.hStdOutput = sockfd; startinfo.hStdError = sockfd; CreateProcess(0, "cmd.exe", NULL, NULL, TRUE, DETACHED_PROCESS, 0, 0, &startinfo, &pinfo);
also would like redirect input+err if possible
•
•
•
•
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.
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
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
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.
![]() |
Similar Threads
- Finding the processor temp (Shell Scripting)
- UNIX TOP (Shell Scripting)
- Help beta testing new CMS (PHP)
- "Forbidden / You don't have permission to access / on this server." error (Linux Servers and Apache)
- This Should be Easy for You Guys! (Linux Servers and Apache)
- another newbie with alot of redhat and apache server Q'S (Linux Servers and Apache)
Other Threads in the C Forum
- Previous Thread: Reading ints from a file
- Next Thread: Needs help on String arrays
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi






