aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/st.c b/st.c
index da832ed..ce32cc0 100644
--- a/st.c
+++ b/st.c
@@ -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 139static void execsh(char *, char **);
140static void execsh(char **);
141static void stty(char **); 140static void stty(char **);
142static void sigchld(int); 141static void sigchld(int);
143static void ttywriteraw(const char *, size_t); 142static void ttywriteraw(const char *, size_t);
@@ -201,15 +200,13 @@ static char *base64dec(const char *);
201static ssize_t xwrite(int, const char *, size_t); 200static ssize_t xwrite(int, const char *, size_t);
202 201
203/* Globals */ 202/* Globals */
204int cmdfd;
205pid_t pid;
206int oldbutton = 3; /* button event on startup: 3 = release */
207
208static Term term; 203static Term term;
209static Selection sel; 204static Selection sel;
210static CSIEscape csiescseq; 205static CSIEscape csiescseq;
211static STREscape strescseq; 206static STREscape strescseq;
212static int iofd = 1; 207static int iofd = 1;
208static int cmdfd;
209static pid_t pid;
213 210
214static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; 211static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
215static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; 212static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
@@ -659,7 +656,7 @@ die(const char *errstr, ...)
659} 656}
660 657
661void 658void
662execsh(char **args) 659execsh(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
748void 745int
749ttynew(char *line, char *out, char **args) 746ttynew(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
799size_t 797size_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
917void
918ttyhangup()
919{
920 /* Send SIGHUP to shell */
921 kill(pid, SIGHUP);
922}
923
919int 924int
920tattrset(int attr) 925tattrset(int attr)
921{ 926{