version 1.32, 2015/10/20 14:55:21 |
version 1.33, 2017/04/12 14:49:05 |
|
|
volatile sig_atomic_t flush; |
volatile sig_atomic_t flush; |
|
|
struct termios tt; |
struct termios tt; |
|
int istty; |
|
|
__dead void done(int); |
__dead void done(int); |
void dooutput(void); |
void dooutput(void); |
|
|
{ |
{ |
extern char *__progname; |
extern char *__progname; |
struct sigaction sa; |
struct sigaction sa; |
struct termios rtt; |
|
struct winsize win; |
struct winsize win; |
char ibuf[BUFSIZ]; |
char ibuf[BUFSIZ]; |
ssize_t cc, off; |
ssize_t cc, off; |
|
|
if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL) |
if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL) |
err(1, "%s", fname); |
err(1, "%s", fname); |
|
|
(void)tcgetattr(STDIN_FILENO, &tt); |
if (isatty(0)) { |
(void)ioctl(STDIN_FILENO, TIOCGWINSZ, &win); |
if (tcgetattr(STDIN_FILENO, &tt) == 0 && |
|
ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == 0) |
|
istty = 1; |
|
} |
if (openpty(&master, &slave, NULL, &tt, &win) == -1) |
if (openpty(&master, &slave, NULL, &tt, &win) == -1) |
err(1, "openpty"); |
err(1, "openpty"); |
|
|
(void)printf("Script started, output file is %s\n", fname); |
(void)printf("Script started, output file is %s\n", fname); |
rtt = tt; |
if (istty) { |
cfmakeraw(&rtt); |
struct termios rtt = tt; |
rtt.c_lflag &= ~ECHO; |
|
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt); |
|
|
|
|
cfmakeraw(&rtt); |
|
rtt.c_lflag &= ~ECHO; |
|
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt); |
|
} |
|
|
bzero(&sa, sizeof sa); |
bzero(&sa, sizeof sa); |
sigemptyset(&sa.sa_mask); |
sigemptyset(&sa.sa_mask); |
sa.sa_handler = handlesigwinch; |
sa.sa_handler = handlesigwinch; |
|
|
(void)fclose(fscript); |
(void)fclose(fscript); |
(void)close(master); |
(void)close(master); |
} else { |
} else { |
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &tt); |
if (istty) |
|
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &tt); |
(void)printf("Script done, output file is %s\n", fname); |
(void)printf("Script done, output file is %s\n", fname); |
} |
} |
exit(eval); |
exit(eval); |