Skip to content

Instantly share code, notes, and snippets.

@AddaxSoft
Forked from vanhoefm/sysdeps\posix\system.c
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AddaxSoft/6402dead0d54ac713607 to your computer and use it in GitHub Desktop.
Save AddaxSoft/6402dead0d54ac713607 to your computer and use it in GitHub Desktop.
Typo correction SELL_PATH => SHELL_PATH
#define SHELL_PATH "/bin/sh" /* Path of the shell. */
#define SHELL_NAME "sh" /* Name to give it. */
static int do_system(const char *line)
{
if (fork() == 0) {
const char *new_argv[4];
new_argv[0] = SHELL_NAME;
new_argv[1] = "-c";
new_argv[2] = line;
new_argv[3] = NULL;
execve(SHELL_PATH, (char *const *) new_argv, __environ);
} else {
// wait on child
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment