1 /* gcc -Wall -O2 -g chpid.c -o chpid */
3 #define _XOPEN_SOURCE_EXTENDED
10 #include <sys/types.h>
12 #include <sys/syscall.h>
15 #include <sys/select.h>
16 #include <sys/resource.h>
17 #include <sys/mount.h>
25 int main(int argc, char **argv, char **envp)
28 printf("Usage: vsyssh <vsys entry> [cmd]\n");
36 inf=(char *)malloc(strlen(argv[1])+3);
37 outf=(char *)malloc(strlen(argv[1])+4);
43 vfd1 = open(inf,O_WRONLY|O_NONBLOCK);
44 vfd0 = open(outf,O_RDONLY|O_NONBLOCK);
46 if (vfd0==-1 || vfd1 == -1) {
47 printf("Error opening vsys entry %s\n", argv[1]);
59 printf("vsys>");fflush(stdout);
62 ret = select(vfd0+1, &set, NULL, NULL, NULL);
63 if (FD_ISSET(0,&set)) {
66 ret=read(0,lineread,2048);
67 write(vfd1,lineread,ret);
69 } if (FD_ISSET(vfd0,&set)) {
72 ret=read(vfd0,lineread,2048);
73 write(1,lineread,ret);
85 execve(argv[3],argv+3,envp);