home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 239.lha / Unix2src.shar / server / sshell.c < prev   
C/C++ Source or Header  |  1989-05-02  |  1KB  |  66 lines

  1.  
  2. /*
  3.  *  S_SHELL.C        OBSOLETE OBSOLETE OBSOLETE
  4.  *
  5.  *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  6.  *
  7.  *   Connect a csh to a pseudo terminal pair... PORT_ALPHATERM
  8.  *   NOTE!!  PORT_IALPHATERM (a pseudo-terminal csh) is also available
  9.  *   through the FTERM client program on the Amiga side, and much faster
  10.  *   since the server for PORT_IALPHATERM is DNET itself (one less process
  11.  *   to go through).
  12.  *
  13.  *    -doesn't handle SIGWINCH
  14.  *    -doesn't handle flow control ... don't cat any long files!
  15.  */
  16.  
  17. #include <stdio.h>
  18. #include <sys/wait.h>
  19. #include <sys/time.h>
  20. #include <sys/resource.h>
  21. #include <errno.h>
  22. #include <signal.h>
  23.  
  24. #include "servers.h"
  25.  
  26. chandler()
  27. {
  28.     union wait stat;
  29.     struct rusage rus;
  30.     while (wait3(&stat, WNOHANG, &rus) > 0);
  31. }
  32.  
  33. main(ac,av)
  34. char *av[];
  35. {
  36.     long chann = DListen(PORT_ALPHATERM);
  37.     int fd;
  38.     int n;
  39.     char buf[256];
  40.     extern int errno;
  41.  
  42.     if (av[1])
  43.     chdir(av[1]);
  44.     signal(SIGCHLD, chandler);
  45.     signal(SIGPIPE, SIG_IGN);
  46.     for (;;) {
  47.     fd = DAccept(chann);
  48.     if (fd < 0) {
  49.         if (errno == EINTR)
  50.         continue;
  51.         break;
  52.     }
  53.     if (fork() == NULL) {
  54.         dup2(fd, 0);
  55.         dup2(fd, 1);
  56.         dup2(fd, 2);
  57.         close(fd);
  58.         execl("/usr/ucb/rlogin", "rlogin", "localhost", NULL);
  59.         exit(1);
  60.     }
  61.     close(fd);
  62.     }
  63.     perror("SSHELL");
  64. }
  65.  
  66.