I am relativly new to C and I am trying to create a basic shell, I am trying to use the execvp function, passing it user input and trying to execute it, the problem I am having is that it does not execute anything, I followed a pdf from here http://www.csc.villanova.edu/~mprobs...5/3.1-Exec.pdf which explained it for me.

here is my code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

static void vsh_cmd_exec(char *cmd[])
{
    int vsh_fork = fork();
    printf("%s\n", cmd[0]); 
    if(vsh_fork == 0)
    {
        execvp(cmd[0], cmd);
        exit(1);
    }else
        wait(NULL);
}

static void vsh_loop(void)
{
    int loop = 1;
    char *cmd = malloc(sizeof(char));

    while(loop == 1)
    {
        printf("[vsh]$ ");
        if(fgets(cmd, 1024, stdin) != NULL)
            vsh_cmd_exec(&cmd);

        fflush(stdin);
    }
    free(cmd);
}

int main(int argc, char *argv[])
{
    if(argc < 2)
        vsh_loop();

    return 0;
}
right now it just prints the user input twice and jumps back to the prompt, instead of executing the command, I have tried running vim first, then ls but neither seem to do anything. Any help would be much great, thank you.