If you have actually fork()ed (or spawn()ed) a child process, and you just want to check whether or not it has terminated, you want the waitpid() function.
You can also use the usleep() function to cause the parent to spin its wheels for a short bit. There are more modern and/or better ways to do this, but this is short and simple...
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
...
int status;
int seconds = 0;
do {
/* Pause for a second */
usleep( 1000000 );
/* Tell the user the number of elapsed seconds */
printf( "\r%d seconds...", ++seconds );
/* Check the child's current status */
waitpid( (pid_t)(-1), &status, WNOHANG );
/* Only break if it has terminated */
} while (!WIFEXITED( status ));
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229