summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/hackvr_term/pty.c
diff options
context:
space:
mode:
authorepoch <epoch@thebackupbox.net>2022-08-17 21:34:02 -0500
committerepoch <epoch@thebackupbox.net>2022-08-17 21:34:02 -0500
commit6492ba6b4107a4da228e18db4fc5fc871bfb0579 (patch)
tree11301c4e20d9a1448337e73b62a16ab1bfeba457 /share/hackvr/examples/hackvr_term/pty.c
parent49d54d7582bdcbdcff5637e72e9f29bb5cc571bd (diff)
downloadhackvr-master.tar.gz
hackvr-master.zip
updated README to show that everything that got deleted went to an -extras repo. also, hackvr script updated to be better bashHEADmaster
Diffstat (limited to 'share/hackvr/examples/hackvr_term/pty.c')
-rw-r--r--share/hackvr/examples/hackvr_term/pty.c70
1 files changed, 0 insertions, 70 deletions
diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c
deleted file mode 100644
index 6903bc3..0000000
--- a/share/hackvr/examples/hackvr_term/pty.c
+++ /dev/null
@@ -1,70 +0,0 @@
-#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>
-#include <errno.h>
-
-int main(int argc,char *argv[]) {
- char *pts;
- 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;
- pts=ptsname(master);
-// printf("%s\n",pts);
-// system("ls -l /dev/pts/*");
- grantpt(master);
- unlockpt(master);
-// system("ls -l /dev/pts/*");
- if(pts == NULL) return 2;
- slave=open(pts,O_RDWR);
- if(slave == -1) {
- perror("open");
- return 3;
- }
- argv++;
- fcntl(master,F_SETFL,O_NONBLOCK);
-// fcntl(slave,F_SETFL,O_NONBLOCK);
- fcntl(0,F_SETFL,O_NONBLOCK);
- fcntl(1,F_SETFL,O_NONBLOCK);
- fcntl(2,F_SETFL,O_NONBLOCK);
- switch(pid=fork()) {
- case -1:
- return 4;//fork failed
- case 0://child
- setsid();
- close(master);
- dup2(slave,0);
- dup2(slave,1);
- dup2(slave,2);
- execv(argv[0],argv);//execute arguments.
- return 5;//exec failed
- default:
- break;
- }
- 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: eof1=1;;//EOF
- case -1: if(errno != EAGAIN) eof1=1; break;//EAGAIN probably.
- default: write(master,&in,r);
- }
- switch(r=read(master,&in,1)) {
- case 0: eof2=1;;//EOF
- case -1: if(errno != EAGAIN) eof2=1; break;//EAGAIN probably
- default: write(1,&in,r);
- }
- usleep(100);//kek
- }
-}