diff options
Diffstat (limited to 'rtty.c')
-rw-r--r-- | rtty.c | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -11,15 +11,16 @@ #include <termios.h> #include <unistd.h> -#define INIT "export TERM=tty43 EDITOR=ed PAGER='pr -ptl22'\n" +#define INIT "export EDITOR=ed PAGER=ul\n" +#define HINIT "export TERM=tty43 EDITOR=ed PAGER=cat\n" #define MAXBUF 2048 #define MAXEARG 32 #define MAXWD 255 char *getpw(char *); -void noop(int); -void killall(int); +void killall(); +void noop(); int main(int argc, char *argv[]) @@ -28,10 +29,12 @@ main(int argc, char *argv[]) *eargv[MAXEARG], in[30], **nargv, out[30], *p, pw[255], *q, wd[MAXWD]; fd_set rfds0, rfds1; - int child, dumb, escape, fdin, fdout, i, n, offset, s, sshpass; + int child, dumb, escape, fdin, fdout, hardcopy, i, n, offset, s, + sshpass; struct timeval tv; - signal(SIGINT, killall); + signal(SIGINT, noop); + signal(SIGQUIT, killall); signal(SIGCHLD, killall); /* Create named pipes. */ @@ -42,9 +45,10 @@ main(int argc, char *argv[]) err(1, "mkfifo"); /* Process rtty-specific flags. */ - escape = dumb = sshpass = 0; + escape = dumb = hardcopy = sshpass = 0; for(;argv[1][0] == '+';){ if(strchr(argv[1], 'd')) dumb = 1; + if(strchr(argv[1], 'h')) hardcopy = 1; if(strchr(argv[1], 'x')) escape = 1; if(strchr(argv[1], 'p')) sshpass = 1; @@ -111,7 +115,10 @@ main(int argc, char *argv[]) err(1, "open"); /* Print initialization command. */ - dprintf(fdin, INIT); + if(hardcopy) + dprintf(fdin, HINIT); + else + dprintf(fdin, INIT); FD_ZERO(&rfds0); FD_ZERO(&rfds1); @@ -198,17 +205,16 @@ found: err(1, "malloc"); if(eargv[i][0] == '/'){ sprintf(p, "%s:%s", address, eargv[i]); - eargv[i]++; }else sprintf(p, "%s:%s/%s", address, wd, eargv[i]); + q = strrchr(eargv[i], '/'); + if(q) eargv[i] = q+1; /* * During the execution of the external commands, - * the SIGCHLD handler is temporarily disabled - * and the SIGINT handler is set to do nothing. + * the SIGCHLD handler is temporarily disabled. */ signal(SIGCHLD, NULL); - signal(SIGINT, noop); /* Download file. */ if((child = fork()) == 0){ @@ -254,7 +260,6 @@ found: /* Clean up. */ done: - signal(SIGINT, killall); signal(SIGCHLD, killall); free(p); @@ -354,12 +359,8 @@ getpw(char *pw) } void -noop(int s) +noop() { - /* - * This handler is active in the parent when an escaped command - * is running. SIGINTs should not affect the parent in any way. - */ } void |