diff options
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -136,8 +136,7 @@ typedef struct { | |||
136 | int narg; /* nb of args */ | 136 | int narg; /* nb of args */ |
137 | } STREscape; | 137 | } STREscape; |
138 | 138 | ||
139 | 139 | static void execsh(char *, char **); | |
140 | static void execsh(char **); | ||
141 | static void stty(char **); | 140 | static void stty(char **); |
142 | static void sigchld(int); | 141 | static void sigchld(int); |
143 | static void ttywriteraw(const char *, size_t); | 142 | static void ttywriteraw(const char *, size_t); |
@@ -201,15 +200,13 @@ static char *base64dec(const char *); | |||
201 | static ssize_t xwrite(int, const char *, size_t); | 200 | static ssize_t xwrite(int, const char *, size_t); |
202 | 201 | ||
203 | /* Globals */ | 202 | /* Globals */ |
204 | int cmdfd; | ||
205 | pid_t pid; | ||
206 | int oldbutton = 3; /* button event on startup: 3 = release */ | ||
207 | |||
208 | static Term term; | 203 | static Term term; |
209 | static Selection sel; | 204 | static Selection sel; |
210 | static CSIEscape csiescseq; | 205 | static CSIEscape csiescseq; |
211 | static STREscape strescseq; | 206 | static STREscape strescseq; |
212 | static int iofd = 1; | 207 | static int iofd = 1; |
208 | static int cmdfd; | ||
209 | static pid_t pid; | ||
213 | 210 | ||
214 | static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; | 211 | static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; |
215 | static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; | 212 | static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; |
@@ -659,7 +656,7 @@ die(const char *errstr, ...) | |||
659 | } | 656 | } |
660 | 657 | ||
661 | void | 658 | void |
662 | execsh(char **args) | 659 | execsh(char *cmd, char **args) |
663 | { | 660 | { |
664 | char *sh, *prog; | 661 | char *sh, *prog; |
665 | const struct passwd *pw; | 662 | const struct passwd *pw; |
@@ -673,7 +670,7 @@ execsh(char **args) | |||
673 | } | 670 | } |
674 | 671 | ||
675 | if ((sh = getenv("SHELL")) == NULL) | 672 | if ((sh = getenv("SHELL")) == NULL) |
676 | sh = (pw->pw_shell[0]) ? pw->pw_shell : shell; | 673 | sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd; |
677 | 674 | ||
678 | if (args) | 675 | if (args) |
679 | prog = args[0]; | 676 | prog = args[0]; |
@@ -745,8 +742,8 @@ stty(char **args) | |||
745 | perror("Couldn't call stty"); | 742 | perror("Couldn't call stty"); |
746 | } | 743 | } |
747 | 744 | ||
748 | void | 745 | int |
749 | ttynew(char *line, char *out, char **args) | 746 | ttynew(char *line, char *cmd, char *out, char **args) |
750 | { | 747 | { |
751 | int m, s; | 748 | int m, s; |
752 | 749 | ||
@@ -765,7 +762,7 @@ ttynew(char *line, char *out, char **args) | |||
765 | die("open line failed: %s\n", strerror(errno)); | 762 | die("open line failed: %s\n", strerror(errno)); |
766 | dup2(cmdfd, 0); | 763 | dup2(cmdfd, 0); |
767 | stty(args); | 764 | stty(args); |
768 | return; | 765 | return cmdfd; |
769 | } | 766 | } |
770 | 767 | ||
771 | /* seems to work fine on linux, openbsd and freebsd */ | 768 | /* seems to work fine on linux, openbsd and freebsd */ |
@@ -786,7 +783,7 @@ ttynew(char *line, char *out, char **args) | |||
786 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); | 783 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); |
787 | close(s); | 784 | close(s); |
788 | close(m); | 785 | close(m); |
789 | execsh(args); | 786 | execsh(cmd, args); |
790 | break; | 787 | break; |
791 | default: | 788 | default: |
792 | close(s); | 789 | close(s); |
@@ -794,6 +791,7 @@ ttynew(char *line, char *out, char **args) | |||
794 | signal(SIGCHLD, sigchld); | 791 | signal(SIGCHLD, sigchld); |
795 | break; | 792 | break; |
796 | } | 793 | } |
794 | return cmdfd; | ||
797 | } | 795 | } |
798 | 796 | ||
799 | size_t | 797 | size_t |
@@ -916,6 +914,13 @@ ttyresize(int tw, int th) | |||
916 | fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); | 914 | fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); |
917 | } | 915 | } |
918 | 916 | ||
917 | void | ||
918 | ttyhangup() | ||
919 | { | ||
920 | /* Send SIGHUP to shell */ | ||
921 | kill(pid, SIGHUP); | ||
922 | } | ||
923 | |||
919 | int | 924 | int |
920 | tattrset(int attr) | 925 | tattrset(int attr) |
921 | { | 926 | { |