I'm writing a shell as a hobby and more specifically because I'm bored but passionate. My shell works great, I even implemented pipelines. But there is one thing that keeps my shell crashing or entering in a for loop and it's only happening when I run bash through my shell.
So I'm in trouble when I issue this command bash -ic <some_command>. If my shell is the default one and I launch an instance and I issue this command above, my shell gets in an infinite loop. Whereas if the default shell is bash and I launch an instance then I run my shell through the first bash prompt and THEN run bash -ic <some_command> through my shell, it gets stopped and I'm back to bash.
Here is a minimal example of the main issue:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void loop_pipe(char ***cmd) 
{
    pid_t pid, wpid;
    int status;
    pid = fork();
    if (pid == 0)
    {
        // Child process
        if (execvp((*cmd)[0],*cmd) == -1)
            perror("Command error");
        exit(EXIT_FAILURE);
    }
    else if (pid < 0)
    {
        // Error forking
        perror("Fork error");
    }
    else
    {
        // Parent process
        do {
            wpid = waitpid(pid, &status, WUNTRACED);
        } while (!WIFEXITED(status) && !WIFSIGNALED(status));
    }
}
int main()
{
    char *ls[] = {"bash", "-ic", "uname", NULL};
    char **cmd[] = {ls, NULL};
    while (1)
    {
        loop_pipe(cmd);
    }
}
The problem here is that after running the command, the process gets stopped so the output is this:
./a.out 
Linux
[4]+  Stopped                 ./a.out
I really don't now what's causing this, but it has to do with bash conflicting with my shell. I also tried to ignore SIGINT and SIGSTOP But it still gets stopped (by bash i guess ?) If someone could help the situation that would be great.
Because my project has more than one source file, I link it not sure if it's right way to do it.