-int tossh, fromssh;
-int io_init(void) {
- int to[2], from[2];
- int pid;
-
- assert(pipe(to) == 0);
- assert(pipe(from) == 0);
- pid = fork();
- assert(pid >= 0);
- if (pid == 0) {
- /* We are child. Dup one end of each pipe to our std[io],
- * close other end, exec. */
- close(0); dup2(to[0], 0); close(to[1]);
- close(1); dup2(from[1], 1); close(from[0]);
- execl("/home/simon/src/openssh/openssh_cvs/prefix/bin/ssh", "ssh", "-2", "simon@localhost", "-s", "sftp", NULL);
- //execl("/root/ssh-research/ssh-2.4.0/apps/ssh/sftp-server2", "sftp-server2", NULL);
- //execl("/usr/lib/sftp-server", "sftp-server", NULL);
- assert(0); /* bomb out if not */
- } else {
- /* We are parent. Close wrong end of each pipe, assign to glob vars. */
- close(to[0]); tossh = to[1];
- close(from[1]); fromssh = from[0];
- }
-}
-int io_finish(void) {
- int pid, status;
- close(tossh);
- close(fromssh);
- pid = wait(&status);
-}