summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/hackvr_term/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'share/hackvr/examples/hackvr_term/pty.c')
-rw-r--r--share/hackvr/examples/hackvr_term/pty.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c
index 1011e38..a3d9951 100644
--- a/share/hackvr/examples/hackvr_term/pty.c
+++ b/share/hackvr/examples/hackvr_term/pty.c
@@ -1,12 +1,15 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
int main(int argc,char *argv[]) {
char *pts;
char in[256];//I dunno.
int r;
int pid;
+ int eof1,eof2;
int master,slave;
master=open("/dev/ptmx",O_RDWR);
if(master == -1) return 1;
@@ -42,18 +45,20 @@ 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);
}
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);
}