MK27's post has the relevant information, so:
Code:
pid_t pid;
int s;
pid = fork();
if(pid == -1) err(1, "fork");
if(pid == 0)
{
execl("/usr/bin/vlc", "vlc", (char *)NULL);
_exit(1);
}
sleep(5);
kill(pid, SIGTERM);
sleep(1);
kill(pid, SIGKILL); /* not strictly necessary, but SIGTERM won't necessarily kill off a process */
if(wait(&s) == -1) err(1, "wait");
if(WIFSIGNALED(s) && (WTERMSIG(s) == SIGTERM || WTERMSIG(s) == SIGKILL)) puts("killed by us");
else if(WIFEXITED(s) && WEXITSTATUS(s) == 0) puts("exited normally");
else puts("something else happened");
The last bit there tries to figure out how the process died, but it's not necessarily accurate. If vlc catches SIGTERM and exits by itself, then WIFSIGNALED(s) will be false. You can circumvent this by always just sending SIGKILL but that's usually a bad idea.