Code: Select all
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
Code: Select all
execl("/bin/bash", "bash", "-c", command, (char *) NULL);
But to be robust, there is more to it, cos the parent should then wait for the child process to terminate and more. Basically needs a new C function call, which is a modified copied of existing system.c (though a much simpler, few lines of code: check SHELL, fork, exec, as above would maybe do in practice...).
EDIT:
One potential problem might be that the shell executed might need to be passed an appropriate environment (variables) so other form of exec maybe needed (I don't know off the top of my head, but maybe execle or execve). One quick explanation of all these different exec calls is given on Wikipedia:
https://en.wikipedia.org/wiki/Exec_(system_call)
(I can't get that link to format properly as a url, sorry. url tags just make post invisible).
wiak