I don't think my question was answered correctly. I don't want to wait because I want the program to run in the background, in this case the ps command. While it's running in the background I want to be able to still control my main program.
Here is an updated version of my excerpt of my program.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <sys/param.h>
#include <signal.h>
main()
{
pid_t childPid;
pid_t pid;
int status;
char test[100];
while(1)
{
printf("%> ");
scanf("%s", &test);
if (strcmp(test,"go") ==0)
{
if ((childPid = fork()) == 0)
{
if ((pid = fork()) != 0)
{
exit(0);
}
if (execlp ("ps", "ps", (char *)0) == -1)
{
perror("exec");
exit(0);
}
}
}
else if (strcmp(test,"exit") ==0)
exit(0);
}
}
Thank you!