system returns -1 on failure to start the program or an error of the wait(2) system call. My guess is that the OP thinks this is returned in $?, since the return value from system is not being checked. Of course, even if the check was correct then it still would not have the desired effect.