here's some more code that exemplifies what i'm trying to do. Still having the same problem.
Code:
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/wait.h>
typedef enum
{
FALSE = 0,
TRUE = 1
} Bool;
int main()
{
pid_t child_pid;
Bool stillGoing = TRUE;
ssize_t readReturn = 0;
size_t bufLen = 0;
char *input = NULL;
int x = 0;
while(stillGoing)
{
printf("Enter some stuff ese: ");
/* The buffer will contain the new line character and the null char */
readReturn = getline(&input, &bufLen, stdin);
/* Get rid of any new line that may be there. */
for(x = 0; x < strlen(input) + 1; ++x)
{
if(input[x] == '\n')
{
input[x] = '\0';
}
}
if(readReturn == 5 && strncmp(input, "exit", 4) == 0)
{
stillGoing = FALSE;
break;
}
if(child_pid == 0)
{
char *argv[]={input, 0};
execvp(argv[0], argv);
perror("execvp() failure!\n");
printf("This print is after execl() and should not get executed\n");
_exit(EXIT_FAILURE);
}
else if(child_pid > 0)
{
wait(0);
}
else
{
perror("Fork Error. Quitting the Programing.\n");
exit(EXIT_FAILURE);
}
input = NULL;
}
}