The purpose of the following code is to complete this goal: launch a process, get its status, and then kill it.
Now, what the code does do it launch the process, gets its status, and then wait for the user to exit off the process manually and then kill the process id. I want it to automatically (sleep for 5 seconds) and kill the process without requiring user input to close the process.Code:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
int main()
{
int g, s;
pid_t c;
if((c = fork()) == 0)
{
execl("/usr/bin/vlc", "vlc", NULL);
}
wait(&s);
kill(c, SIGKILL);
return 0;
}
My question is how can I get the status of my child process, wait 5 seconds, and then kill the process?
I hope I explained what I need the code to do well, if not, ask me questions and I will answer them to the best of my ability.
Thank you!

