When execl fails in C

when execl fails using the command lss, it doesnt go into the next line

        execl("/bin/sh", "/bin/sh", "-c", command, NULL); 
        perror("execl failed"); exit(127);

for some reason the child process just stops and also the parent process also stops
so the line after the line that called the function that runs execl, doesnt run...
its supposed to return a 127 value but it returns a 31 instead...

anyone know why?

But it's not running lss -- it's running /bin/sh. execl will succeed even if command contains complete garbage. /bin/sh will complain about command not found though, but that's not the same thing as execl failing.

maybe it is because a signal in the child process forced the main process quit. you can catch the terminal signals or ignore them.

There is no parent process and child process in the code snippet you posted.

execl replaces the current program with a new one (in this case "/bin/sh"), all in the same process. By the time that /bin/sh generates the error, your execl and perror are long gone.

If you want to be able to continue after the execl, you need to put in in a child process (fork), wait for the child to terminate (wait or waitpid) and recover the exit status from the status variable written by wait/waitpid.