X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vsyssh%2Fvsyssh.c;h=0239fec948548d780807119f1d4c78b5d7c0234e;hb=26326ab885a36f7e0661703b735109df36520b30;hp=889e41a11882c810997951443db250b9d456fcd4;hpb=7e6d4cb025ff03b9fee5337b0d87f6849bf1f21c;p=vsys.git diff --git a/vsyssh/vsyssh.c b/vsyssh/vsyssh.c index 889e41a..0239fec 100644 --- a/vsyssh/vsyssh.c +++ b/vsyssh/vsyssh.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,10 @@ #include #include +void pipe_handler (int sig) { + printf("SIGPIPE"); +} + int main(int argc, char **argv, char **envp) { if (argc<2) { @@ -33,6 +38,7 @@ int main(int argc, char **argv, char **envp) char *inf,*outf; struct timeval tv; + signal(SIGPIPE,pipe_handler); inf=(char *)malloc(strlen(argv[1])+3); outf=(char *)malloc(strlen(argv[1])+4); strcpy(inf,argv[1]); @@ -40,11 +46,13 @@ int main(int argc, char **argv, char **envp) strcat(inf,".in"); strcat(outf,".out"); - vfd1 = open(inf,O_WRONLY|O_NONBLOCK); vfd0 = open(outf,O_RDONLY|O_NONBLOCK); + printf("Out file: %d\n",vfd0); + vfd1 = open(inf,O_WRONLY); + printf("In file: %d\n",vfd1); if (vfd0==-1 || vfd1 == -1) { - printf("Error opening vsys entry %s\n", argv[1]); + printf("Error opening vsys entry %s (%s)\n", argv[1],strerror(errno)); exit(1); } @@ -54,7 +62,8 @@ int main(int argc, char **argv, char **envp) FD_SET(0, &set); FD_SET(vfd0, &set); - while (1) { + while (1) + { int ret; printf("vsys>");fflush(stdout); FD_SET(0, &set); @@ -64,6 +73,8 @@ int main(int argc, char **argv, char **envp) char lineread[2048]; int ret; ret=read(0,lineread,2048); + lineread[ret]='\0'; + printf ("writing %s\n",lineread); write(vfd1,lineread,ret); FD_CLR(0,&set); } if (FD_ISSET(vfd0,&set)) {