git://git.onelab.eu
/
vsys.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Undo change to tag, commit to trunk instead
[vsys.git]
/
vsyssh
/
vsyssh.c
diff --git
a/vsyssh/vsyssh.c
b/vsyssh/vsyssh.c
index
7ae4deb
..
0239fec
100644
(file)
--- a/
vsyssh/vsyssh.c
+++ b/
vsyssh/vsyssh.c
@@
-6,6
+6,7
@@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
@@
-22,47
+23,61
@@
#include <stdarg.h>
#include <dirent.h>
#include <stdarg.h>
#include <dirent.h>
+void pipe_handler (int sig) {
+ printf("SIGPIPE");
+}
+
int main(int argc, char **argv, char **envp)
{
if (argc<2) {
int main(int argc, char **argv, char **envp)
{
if (argc<2) {
- printf("Usage: vsyssh <vsys entry>
<cmd>
\n");
+ printf("Usage: vsyssh <vsys entry>
[cmd]
\n");
exit(1);
}
else {
int vfd0,vfd1;
char *inf,*outf;
exit(1);
}
else {
int vfd0,vfd1;
char *inf,*outf;
+ struct timeval tv;
+
+ signal(SIGPIPE,pipe_handler);
inf=(char *)malloc(strlen(argv[1])+3);
inf=(char *)malloc(strlen(argv[1])+3);
- outf=(char *)malloc(strlen(argv[
2
])+4);
+ outf=(char *)malloc(strlen(argv[
1
])+4);
strcpy(inf,argv[1]);
strcpy(inf,argv[1]);
- strcpy(
inf,argv[2
]);
+ strcpy(
outf,argv[1
]);
strcat(inf,".in");
strcat(outf,".out");
strcat(inf,".in");
strcat(outf,".out");
+ vfd0 = open(outf,O_RDONLY|O_NONBLOCK);
+ printf("Out file: %d\n",vfd0);
vfd1 = open(inf,O_WRONLY);
vfd1 = open(inf,O_WRONLY);
-
vfd0 = open(outf,O_RDONLY
);
+
printf("In file: %d\n",vfd1
);
if (vfd0==-1 || vfd1 == -1) {
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);
}
exit(1);
}
-
if (argc<3) {
fd_set set;
FD_ZERO(&set);
if (argc<3) {
fd_set set;
FD_ZERO(&set);
- FD_SET(0,&set);
- FD_SET(vfd0,&set);
- while (1) {
+ FD_SET(0, &set);
+ FD_SET(vfd0, &set);
+
+ while (1)
+ {
int ret;
int ret;
- ret = select(2, &set, NULL, NULL, NULL);
+ printf("vsys>");fflush(stdout);
+ FD_SET(0, &set);
+ FD_SET(vfd0, &set);
+ ret = select(vfd0+1, &set, NULL, NULL, NULL);
if (FD_ISSET(0,&set)) {
char lineread[2048];
int ret;
ret=read(0,lineread,2048);
if (FD_ISSET(0,&set)) {
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);
write(vfd1,lineread,ret);
FD_CLR(0,&set);
- }
- else if (FD_ISSET(vfd0,&set)) {
+ } if (FD_ISSET(vfd0,&set)) {
char lineread[2048];
int ret;
ret=read(vfd0,lineread,2048);
char lineread[2048];
int ret;
ret=read(vfd0,lineread,2048);