Fixed crashing on no input
This commit is contained in:
parent
a0d601f1e3
commit
8bd2940f1a
@ -180,6 +180,7 @@ int ExecPipe(CommandStruct* commandParent, CommandStruct* commandChild, int* pip
|
||||
int pipeLocation = 0;
|
||||
int startArgc = 0;
|
||||
int endArgc = commandParent->argc;
|
||||
pipe(pipefd);
|
||||
for (int i = 0; i < pipeAmount; i++)
|
||||
{
|
||||
|
||||
@ -191,24 +192,27 @@ int ExecPipe(CommandStruct* commandParent, CommandStruct* commandChild, int* pip
|
||||
// if (pipeLocation < 0)
|
||||
// endArgc = commandParent->argc;
|
||||
CopyCommandStruct(commandParent, commandChild, startArgc, endArgc);
|
||||
pipe(pipefd);
|
||||
forkPID = fork();
|
||||
if (forkPID == 0)
|
||||
return forkPID;
|
||||
// if (forkPID != 0)
|
||||
wait(&forkPID);
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
while (read(pipefd[0], buffer, sizeof(buffer)) != 0)
|
||||
printf("%s", buffer);
|
||||
wait(&forkPID);
|
||||
startArgc = pipeLocation + 1;
|
||||
ResetCommandStruct(commandChild); // Clean command
|
||||
pipe(pipefd);
|
||||
}
|
||||
endArgc = commandParent->argc;
|
||||
forkPID = fork();
|
||||
CopyCommandStruct(commandParent, commandChild, startArgc, endArgc);
|
||||
if (forkPID == 0)
|
||||
return forkPID;
|
||||
close(pipefd[1]);
|
||||
wait(&forkPID);
|
||||
while (read(pipefd[0], buffer, sizeof(buffer)) != 0)
|
||||
printf("%s", buffer);
|
||||
close(pipefd[0]);
|
||||
ResetCommandStruct(commandChild); // Clean command
|
||||
return 1;
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ void Pish(void)
|
||||
ResetCommandStruct(commandParent); // Clean command
|
||||
strcpy(inputString, ""); // Clean inputString
|
||||
GetInput(inputString);
|
||||
if (strcmp(inputString, "") == 0)
|
||||
continue;
|
||||
SplitInput(inputString, commandParent);
|
||||
if (IntegratedCheck(commandParent))
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user