// spawn a program, redirecting output to stdin/out
// using /proc filesystem.

#include <iostream.h>
#include <string.h>
#include <stdio.h> // sprintf()
#include "client.h"
#include "daemon.h"
#include <stdlib.h>


int main (int argc, char **argv) {
  if (server_init() < 0) {
    exit(-1);
  }
  char cmd[255];
#if 0
  sprintf (cmd, "lredir z: linux\\fs\\proc\\%d\\fd", getpid());
  Daemon_spawn (cmd);
  sprintf (cmd, "%s < z:\\0 >& z:\\1 ", argv[1]);
  Daemon_spawn (cmd);
  Daemon_spawn ("lredir del z:");
#else
  
//  sprintf (cmd, "lredir z: linux\\fs\\proc", getpid());
  Daemon_spawn (cmd);
  sprintf (cmd, "%s < z:\\%d\\fd\\0 >& z:\\%d\\fd\\1 ", argv[1], getpid(), getpid());
  Daemon_spawn (cmd);
//  Daemon_spawn ("lredir del z:");
#endif
  server_exit();
  
}
  
