I want my child process to execute a bin program when my parent waits for 3 seconds and kills the child. Silly I know, but still gotta do it. Cant seem to use the execv properly here.I've tried to run calendar, gedit etc. just hasn't worked for me. Any suggestions ?
int main(int argc, char* argv[])
{
pid_t pid;
pid = fork();
if (pid == 0) {
execv("calc",argv);
return 0;
}
else if (pid > 0) { /* parent process */
sleep(3);
kill(pid, SIGKILL);
printf("Child process with the ID: %d has been killed by the parent process with the ID: %d...\n", pid, getpid());
return 0;
}
}