More experimental tty stdio work

This commit is contained in:
Andrew Pamment 2016-03-26 11:23:57 +10:00
parent e6c99a06d1
commit ccec36b07c

15
doors.c
View File

@ -6,6 +6,7 @@
#include <unistd.h> #include <unistd.h>
#include <libgen.h> #include <libgen.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/ioctl.h>
#if defined(linux) #if defined(linux)
# include <pty.h> # include <pty.h>
#else #else
@ -118,6 +119,9 @@ void rundoor(int socket, struct user_record *user, char *cmd, int stdio) {
int slave; int slave;
fd_set fdset; fd_set fdset;
int t; int t;
int pipefd[2];
if (write_door32sys(socket, user) != 0) { if (write_door32sys(socket, user) != 0) {
return; return;
@ -137,10 +141,21 @@ void rundoor(int socket, struct user_record *user, char *cmd, int stdio) {
if (pid < 0) { if (pid < 0) {
return; return;
} else if (pid == 0) { } else if (pid == 0) {
close(master);
dup2(slave, 0); dup2(slave, 0);
dup2(slave, 1); dup2(slave, 1);
close(slave);
setsid();
ioctl(0, TIOCSCTTY, 1);
execvp(cmd, arguments); execvp(cmd, arguments);
} else { } else {
pipe(pipefd);
while(1) { while(1) {
FD_ZERO(&fdset); FD_ZERO(&fdset);
FD_SET(master, &fdset); FD_SET(master, &fdset);