Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
ok i need some major help with my program. I am trying to create 2 process in main and then have them communicate via a pipe. the problem right now is occuring whenever i create my first process. Within the process I am simply just printing a sentence. For some reason though my program only outputs 8 charcters and then a bunch of garbage. Here is my code. any help is greatly appreciated
#include
#include
#include
#include
#include
#include
#includeHANDLE readpipe,writepipe;
SECURITY_ATTRIBUTES pipeSA;
STARTUPINFO srcStartInfo, sinkStartInfo;
PROCESS_INFORMATION sourceinfo, sinkinfo;void main()
{
//create pipe
pipeSA.nLength = sizeof(SECURITY_ATTRIBUTES);
pipeSA.bInheritHandle = true;
pipeSA.lpSecurityDescriptor = NULL;if(!CreatePipe(&readpipe, &writepipe, &pipeSA, 0)){printf("ERROR");ExitProcess(1);}
char * sourcename = "source.exe";
char * sinkname = "sink.exe";//Create Process source;
ZeroMemory(&srcStartInfo,sizeof(STARTUPINFO));
srcStartInfo.cb = sizeof(srcStartInfo);
srcStartInfo.hStdOutput = writepipe;
srcStartInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
srcStartInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
srcStartInfo.dwFlags = STARTF_USESTDHANDLES;
if(!CreateProcess(NULL,sourcename,NULL, NULL, false, NORMAL_PRIORITY_CLASS ,NULL, NULL, &srcStartInfo, &sourceinfo)){printf("error creating source");ExitProcess(1);}
//create process sink
ZeroMemory(&sinkStartInfo,sizeof(STARTUPINFO));
sinkStartInfo.cb = sizeof(STARTUPINFO);
sinkStartInfo.hStdInput = readpipe;
sinkStartInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
sinkStartInfo.dwFlags = STARTF_USESTDHANDLES;
if(!CreateProcess(NULL,sinkname,NULL, NULL, false, NORMAL_PRIORITY_CLASS,NULL, NULL, &sinkStartInfo, &sinkinfo)){printf("error creating sink");ExitProcess(1);}

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |