aboutsummaryrefslogtreecommitdiff
path: root/cmd/runsvc
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-09-16 21:52:46 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-09-19 12:22:14 +0200
commitf38163772cb8ca25c440393132e8678e65437320 (patch)
treee0ad42ce3b374dda60ce92eab7f2f5fbca8722b4 /cmd/runsvc
parent5cd5f48f765f00b81786c6f569314474a91a06b8 (diff)
Add simple cron implementation
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'cmd/runsvc')
-rw-r--r--cmd/runsvc/runsvc.c47
1 files changed, 1 insertions, 46 deletions
diff --git a/cmd/runsvc/runsvc.c b/cmd/runsvc/runsvc.c
index 9e646e7..e36010b 100644
--- a/cmd/runsvc/runsvc.c
+++ b/cmd/runsvc/runsvc.c
@@ -17,51 +17,6 @@
*/
#include "runsvc.h"
-static int setup_tty(service_t *svc)
-{
- int fd;
-
- if (svc->ctty != NULL) {
- fd = open(svc->ctty, O_RDWR);
- if (fd < 0) {
- perror(svc->ctty);
- return -1;
- }
-
- if (svc->flags & SVC_FLAG_TRUNCATE_OUT)
- ftruncate(fd, 0);
-
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
- setsid();
-
- dup2(fd, STDIN_FILENO);
- dup2(fd, STDOUT_FILENO);
- dup2(fd, STDERR_FILENO);
- close(fd);
- }
-
- return 0;
-}
-
-/*****************************************************************************/
-
-static NORETURN void argv_exec(exec_t *e)
-{
- char **argv = alloca(e->argc + 1), *ptr;
- int i;
-
- for (ptr = e->args, i = 0; i < e->argc; ++i, ptr += strlen(ptr) + 1)
- argv[i] = ptr;
-
- argv[i] = NULL;
- execvp(argv[0], argv);
- perror(argv[0]);
- exit(EXIT_FAILURE);
-}
-
static int runlst_wait(exec_t *list)
{
pid_t ret, pid;
@@ -128,7 +83,7 @@ int main(int argc, char **argv)
if (initenv())
goto out;
- if (setup_tty(svc))
+ if (setup_tty(svc->ctty, (svc->flags & SVC_FLAG_TRUNCATE_OUT) != 0))
goto out;
if (svc->exec->next == NULL)