summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-11-04 16:50:54 +0100
committerSteven Barth <steven@midlink.org>2014-11-04 16:54:10 +0100
commit44803f0b48e6b0bbc56b1f9f8c2ea9c8e1003302 (patch)
tree824945b08a3d953a099361ed33c22bf7c24b4deb /utils
parent174777181850705df7c6dbe234bd7e93d352666a (diff)
downloadunitd-44803f0b48e6b0bbc56b1f9f8c2ea9c8e1003302.tar
unitd-44803f0b48e6b0bbc56b1f9f8c2ea9c8e1003302.zip
Honour tty field in /etc/inittab
The problem was caused by procd not opening /dev/tty* (whichever was specified for the ID field /etc/inittab), causing /proc/PID/fd to point to /dev/console instead. This is a rework of e63051d9, which did not initialise the console pointer and did not check the tty pointer in askconsole. askfirst was not completely fixed as it expected the console parameter on the commandline, which is no longer necessary because procd opens the console prior to fork()-ing. Signed-off-by: Michel Stam <m.stam@fugro.nl>
Diffstat (limited to 'utils')
-rw-r--r--utils/askfirst.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/utils/askfirst.c b/utils/askfirst.c
index 6ad77aa..e78823c 100644
--- a/utils/askfirst.c
+++ b/utils/askfirst.c
@@ -19,34 +19,10 @@
#include <unistd.h>
#include <fcntl.h>
-static int redirect_output(const char *dev)
-{
- pid_t p = setsid();
- int fd;
-
- chdir("/dev");
- fd = open(dev, O_RDWR);
- chdir("/");
-
- if (fd < 0)
- return -1;
-
- dup2(fd, STDIN_FILENO);
- dup2(fd, STDOUT_FILENO);
- dup2(fd, STDERR_FILENO);
- tcsetpgrp(fd, p);
- close(fd);
-
- return 0;
-}
-
int main(int argc, char **argv)
{
int c;
- if (redirect_output(argv[1]))
- fprintf(stderr, "%s: Failed to open %s\n", argv[0], argv[1]);
-
printf("Please press Enter to activate this console.\n");
do {
c = getchar();
@@ -55,8 +31,8 @@ int main(int argc, char **argv)
}
while (c != 0xA);
- execvp(argv[2], &argv[2]);
- printf("%s: Failed to execute %s\n", argv[0], argv[2]);
+ execvp(argv[1], &argv[1]);
+ printf("Failed to execute %s\n", argv[0]);
return -1;
}