*** libsock/serial.c-	Mon Aug 24 00:03:33 1998
--- libsock/serial.c	Thu Dec  3 20:59:37 1998
***************
*** 284,291 ****
--- 284,293 ----
    if(ps->mac->fd) { /* If device was opened */
      if (ps->connected) {
        pi_serial_flush(ps); /* Flush the device, and set baud rate back to the initial setting */
+ #ifdef notdef
        ps->rate = 9600; 
        ps->serial_changebaud(ps);
+ #endif
      }
      if (--(ps->mac->ref) == 0) { /* If no-one is using the device, close it */
        ps->serial_close(ps);
*** libsock/unixserial.c-	Mon Aug 24 00:04:56 1998
--- libsock/unixserial.c	Thu Dec  3 20:56:38 1998
***************
*** 226,232 ****
  #endif
  
  /* Unspecified NetBSD versions fail to flush hardware FIFO on port close */
! #ifdef __NetBSD__
  # define sleeping_beauty
  #endif
  
--- 226,232 ----
  #endif
  
  /* Unspecified NetBSD versions fail to flush hardware FIFO on port close */
! #if defined(__NetBSD__) || defined (__OpenBSD__)
  # define sleeping_beauty
  #endif
  
***************
*** 235,250 ****
  # define sleeping_beauty
  #endif
  
  static int s_changebaud(struct pi_socket *ps)
  {
  #ifndef SGTTY
    struct termios tcn;
  
  #ifdef sleeping_beauty
!   struct timeval tv; 
!   tv.tv_sec = 0;
!   tv.tv_usec = 50000;
!   select(0,0,0,0, &tv);
  #endif
  
    /* Set the tty to the new speed */
--- 235,257 ----
  # define sleeping_beauty
  #endif
  
+ #ifdef sleeping_beauty
+ static s_delay(int sec, int usec)
+ {
+   struct timeval tv; 
+   tv.tv_sec = sec;
+   tv.tv_usec = usec;
+   select(0,0,0,0, &tv);
+ }
+ #endif
+ 
  static int s_changebaud(struct pi_socket *ps)
  {
  #ifndef SGTTY
    struct termios tcn;
  
  #ifdef sleeping_beauty
!   s_delay(0, 200000);
  #endif
  
    /* Set the tty to the new speed */
***************
*** 256,264 ****
    tcsetattr(ps->mac->fd,TCSADRAIN,&tcn);
  
  #ifdef sleeping_beauty
!   tv.tv_sec = 0;
!   tv.tv_usec = 50000;
!   select(0,0,0,0, &tv);
  #endif
  
  #else
--- 263,269 ----
    tcsetattr(ps->mac->fd,TCSADRAIN,&tcn);
  
  #ifdef sleeping_beauty
!   s_delay(0, 200000);
  #endif
  
  #else
***************
*** 280,285 ****
--- 285,293 ----
  static int s_close(struct pi_socket *ps)
  {
    int result;
+ #ifdef sleeping_beauty
+   s_delay(2, 0);
+ #endif
  #ifndef SGTTY
  
    tcsetattr(ps->mac->fd,TCSADRAIN, &ps->tco);
***************
*** 289,294 ****
--- 297,303 ----
  
  #endif
      
+   s_delay(4, 0);
    result = close(ps->mac->fd);
    ps->mac->fd = 0;
  
