summaryrefslogtreecommitdiffstats
path: root/askconsole.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-11-30 14:49:56 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-11-30 15:03:56 +0100
commitd905c9da4d8984f19cd74a17cebd2743d399b035 (patch)
tree8a7db7d0ef9d8ce2ed0750da1e6286bbc0aadc41 /askconsole.c
parent9f5b52ee3240dc61b0cae882dd880fd2ff28edf4 (diff)
downloadunitd-d905c9da4d8984f19cd74a17cebd2743d399b035.tar
unitd-d905c9da4d8984f19cd74a17cebd2743d399b035.zip
Reorganize source directory
Diffstat (limited to 'askconsole.c')
-rw-r--r--askconsole.c63
1 files changed, 0 insertions, 63 deletions
diff --git a/askconsole.c b/askconsole.c
deleted file mode 100644
index fe37141..0000000
--- a/askconsole.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include "unitd.h"
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-
-
-static void askconsole(struct uloop_process *proc) {
- char *const ask[] = {
- "/sbin/askfirst",
- "/bin/ash",
- "--login",
- NULL,
- };
-
- pid_t p;
-
- proc->pid = fork();
- if (!proc->pid) {
- p = setsid();
-
- fcntl(STDERR_FILENO, F_SETFL, fcntl(STDERR_FILENO, F_GETFL) & ~O_NONBLOCK);
-
- ioctl(STDIN_FILENO, TIOCSCTTY, 1);
- tcsetpgrp(STDIN_FILENO, p);
-
- execvp(ask[0], ask);
- ERROR("Failed to execute %s\n", ask[0]);
- exit(-1);
- }
-
- if (proc->pid > 0) {
- DEBUG(4, "Launched askconsole, pid=%d\n",
- (int) proc->pid);
- uloop_process_add(proc);
- }
-}
-
-static void child_exit(struct uloop_process *proc, int ret)
-{
- DEBUG(4, "pid:%d\n", proc->pid);
- askconsole(proc);
-}
-
-void unitd_askconsole(void) {
- struct uloop_process *proc = calloc(1, sizeof(*proc));
- proc->cb = child_exit;
- askconsole(proc);
-}