summaryrefslogtreecommitdiff
path: root/share/hackvr/examples
diff options
context:
space:
mode:
authorepoch <epoch@thebackupbox.net>2020-04-06 05:55:20 -0500
committerepoch <epoch@thebackupbox.net>2020-04-06 05:55:20 -0500
commit2eea5bc2684c84aeaeba4a1f374ab96eb74b7885 (patch)
tree5fa74798c5f9c2ca7f00ead19032865f0407d22f /share/hackvr/examples
parent167169abe4df9bd67b5994b6a665abb437947815 (diff)
downloadhackvr-2eea5bc2684c84aeaeba4a1f374ab96eb74b7885.tar.gz
hackvr-2eea5bc2684c84aeaeba4a1f374ab96eb74b7885.zip
fixed hackvr_term's pty.c so I don't have to use python for getting a pty.
Diffstat (limited to 'share/hackvr/examples')
-rw-r--r--share/hackvr/examples/hackvr_term/pty.c19
1 files changed, 13 insertions, 6 deletions
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 <stdio.h>
#include <fcntl.h>
#include <sys/wait.h>
+#include <stdlib.h>
+#include <unistd.h>
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
}