From f38163772cb8ca25c440393132e8678e65437320 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 16 Sep 2018 21:52:46 +0200 Subject: Add simple cron implementation Signed-off-by: David Oberhollenzer --- cmd/runsvc/runsvc.c | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'cmd/runsvc') 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) -- cgit v1.2.3