From 937ae3b5d2b4f3e63d23d1911f77d806ccb96d5d Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Wed, 5 Feb 2020 13:07:56 -0800 Subject: [PATCH] Added pid check for forkpty() initialization --- microstack/ILibProcessPipe.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/microstack/ILibProcessPipe.c b/microstack/ILibProcessPipe.c index 6c9a762..dbe8e70 100644 --- a/microstack/ILibProcessPipe.c +++ b/microstack/ILibProcessPipe.c @@ -955,13 +955,16 @@ ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx4(ILibProcessPipe_ pid = forkpty(&pipe, NULL, flags == 0 ? NULL : &tios, &w); - retVal->PTY = pipe; - retVal->stdIn = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(pipeManager, pipe, extraMemorySize); - retVal->stdOut = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(pipeManager, pipe, extraMemorySize); + if (pid > 0) + { + retVal->PTY = pipe; + retVal->stdIn = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(pipeManager, pipe, extraMemorySize); + retVal->stdOut = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(pipeManager, pipe, extraMemorySize); - retVal->stdIn->mProcess = retVal; - ILibProcessPipe_Pipe_SetBrokenPipeHandler(retVal->stdOut, ILibProcessPipe_Process_BrokenPipeSink); - retVal->stdOut->mProcess = retVal; + retVal->stdIn->mProcess = retVal; + ILibProcessPipe_Pipe_SetBrokenPipeHandler(retVal->stdOut, ILibProcessPipe_Process_BrokenPipeSink); + retVal->stdOut->mProcess = retVal; + } } else {