Add shell_exec() function

Can be used to execute an external program in a shell.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-07-01 16:40:54 +02:00
parent 7e61b3de06
commit 7982c98be4
2 changed files with 9 additions and 0 deletions

View File

@ -880,6 +880,7 @@ void str_toupper (char *);
void file_close (FILE *, const char *);
void psleep (unsigned);
int fork_exec (int *, int *, const char *, char *const *);
int shell_exec (int *, int *, char *);
int child_wait (int *, int *, int);
/* vars.c */

View File

@ -791,6 +791,14 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
return pid;
}
/* Execute an external program in a shell. */
int
shell_exec (int *pfdin, int *pfdout, char *cmd)
{
char *arg[] = { "/bin/sh", "-c", cmd, NULL };
return fork_exec (pfdin, pfdout, *arg, arg);
}
/* Wait for a child process to terminate. */
int
child_wait (int *pfdin, int *pfdout, int pid)