*** dos.c.old	Sat Aug 12 22:36:06 2000
--- dos.c	Sat Aug 12 22:42:08 2000
***************
*** 1308,1313 ****
--- 1308,1329 ----
  ** write
  */
  static int
+ write_or_truncate(int fd, char *addr, int len)
+ {
+     off_t offset;
+ 
+     if ( len == 0 ){
+ 	offset = lseek(fd,0,SEEK_CUR);
+ 	if( offset < 0 )
+ 	    return -1;
+ 	else
+ 	    return ftruncate(fd,offset);
+     } else {
+ 	return write(fd,addr,len);
+     }
+ }
+ 
+ static int
  int21_40(regcontext_t *REGS)
  {
      char	*addr;
***************
*** 1321,1327 ****
      switch (R_BX) {
      case 0:
  	if (redirect0) {
! 	    n = write (R_BX, addr, nbytes);
  	    break;
  	}
  	n = nbytes;
--- 1337,1343 ----
      switch (R_BX) {
      case 0:
  	if (redirect0) {
! 	    n = write_or_truncate (R_BX, addr, nbytes);
  	    break;
  	}
  	n = nbytes;
***************
*** 1330,1336 ****
  	break;
      case 1:
  	if (redirect1) {
! 	    n = write (R_BX, addr, nbytes);
  	    break;
  	}
  	n = nbytes;
--- 1346,1352 ----
  	break;
      case 1:
  	if (redirect1) {
! 	    n = write_or_truncate (R_BX, addr, nbytes);
  	    break;
  	}
  	n = nbytes;
***************
*** 1339,1345 ****
  	break;
      case 2:
  	if (redirect2) {
! 	    n = write (R_BX, addr, nbytes);
  	    break;
  	}
  	n = nbytes;
--- 1355,1361 ----
  	break;
      case 2:
  	if (redirect2) {
! 	    n = write_or_truncate (R_BX, addr, nbytes);
  	    break;
  	}
  	n = nbytes;
***************
*** 1347,1353 ****
  	    tty_write(*addr++, -1);
  	break;
      default:
! 	n = write (R_BX, addr, nbytes);
  	break;
      }
      if (n < 0)
--- 1363,1369 ----
  	    tty_write(*addr++, -1);
  	break;
      default:
! 	n = write_or_truncate (R_BX, addr, nbytes);
  	break;
      }
      if (n < 0)
