From 2eea5bc2684c84aeaeba4a1f374ab96eb74b7885 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 05:55:20 -0500 Subject: fixed hackvr_term's pty.c so I don't have to use python for getting a pty. --- share/hackvr/examples/hackvr_term/pty.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'share') diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c index 1011e38..d894359 100644 --- a/share/hackvr/examples/hackvr_term/pty.c +++ b/share/hackvr/examples/hackvr_term/pty.c @@ -1,12 +1,17 @@ +#define _XOPEN_SOURCE 500 //ptsname +#define _XOPEN_SOURCE_EXTENDED #include #include #include +#include +#include int main(int argc,char *argv[]) { char *pts; - char in[256];//I dunno. + char in;//I dunno. int r; int pid; + int eof1,eof2; int master,slave; master=open("/dev/ptmx",O_RDWR); if(master == -1) return 1; @@ -42,20 +47,22 @@ int main(int argc,char *argv[]) { default: break; } - for(;;) { + eof1=0; + eof2=0; + for(;!(eof1 || eof2);) { if(waitpid(-1,0,WNOHANG) > 0) { return 0;//fuck if I know. //we got a dead child. let's bail. } switch(r=read(0,&in,1)) { - case 0: return 6;//EOF + case 0: eof1=1;;//EOF case -1: break;//EAGAIN probably. - default: write(master,in,r); + default: write(master,&in,r); } switch(r=read(master,&in,1)) { - case 0: return 7;//EOF + case 0: eof2=1;;//EOF case -1: break;//EAGAIN probably - default: write(1,in,r); + default: write(1,&in,r); } usleep(100);//kek } -- cgit v1.2.3