summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-07-01 16:40:54 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-02 10:15:36 +0200
commit7982c98be4180c17c90e656bbf1f61e94ceaad69 (patch)
treebcf0450fd32397f6d9393df7684f73e171d25e48 /src
parent7e61b3de06a190aa9e84b3fc0070ee27e57770d1 (diff)
downloadcalcurse-7982c98be4180c17c90e656bbf1f61e94ceaad69.zip
Add shell_exec() function
Can be used to execute an external program in a shell. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.h1
-rw-r--r--src/utils.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index dec14c4..14becbd 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -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 */
diff --git a/src/utils.c b/src/utils.c
index 75e702b..5f19db0 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -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)