home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / c / csh4.zip / STDSAVE.C < prev    next >
C/C++ Source or Header  |  1985-09-03  |  438b  |  29 lines

  1. #include <stdio.h>
  2. #include <fcntl.h>
  3.  
  4. int console;
  5. int in,out;    /* old standard input and standard output */
  6. std_save()
  7. {
  8.     if (-1 == (console = open("con",O_RDWR)))
  9.     {
  10.         perror("sh : can't open console");
  11.         return -1;
  12.     }
  13.     in = dup(0);
  14.     out = dup(1);
  15.     fdup(console,0);
  16.     fdup(console,1);
  17.     fdup(console,2);
  18.     return 0;
  19. }
  20. void 
  21. std_restore()
  22. {
  23.     fdup(in,0);
  24.     fdup(out,1);
  25.     close(console);
  26.     close(in);
  27.     close(out);
  28. }
  29.