Kaynağa Gözat

Running ltp 20030905 showed that tcsendbreak was broken.
This fixes it.

Eric Andersen 22 yıl önce
ebeveyn
işleme
b9c0292271
1 değiştirilmiş dosya ile 13 ekleme ve 11 silme
  1. 13 11
      libc/termios/termios.c

+ 13 - 11
libc/termios/termios.c

@@ -70,21 +70,23 @@ int tcflush ( int fd, int queue_selector)
 /* Send zero bits on FD.  */
 /* Send zero bits on FD.  */
 int tcsendbreak( int fd, int duration)
 int tcsendbreak( int fd, int duration)
 {
 {
-	/*
+	/* The break lasts 0.25 to 0.5 seconds if DURATION is zero,
-	 * The break lasts 0.25 to 0.5 seconds if DURATION is zero, and an
+	   and an implementation-defined period if DURATION is nonzero.
-	 * implementation-defined period if DURATION is nonzero. We define a
+	   We define a positive DURATION to be number of milliseconds to break.  */
-	 * positive DURATION to be number of milliseconds to break.
-	 */
 	if (duration <= 0)
 	if (duration <= 0)
 		return ioctl(fd, TCSBRK, 0);
 		return ioctl(fd, TCSBRK, 0);
 
 
-	/*
+#ifdef TCSBRKP
-	 * ioctl can't send a break of any other duration for us. This could be
+	/* Probably Linux-specific: a positive third TCSBRKP ioctl argument is
-	 * changed to use trickery (e.g. lower speed and send a '\0') to send
+	   defined to be the number of 100ms units to break.  */
-	 * the break, but for now just return an error.
+	return ioctl(fd, TCSBRKP, (duration + 99) / 100);
-	 */
+#else
-	__set_errno(EINVAL);
+	/* ioctl can't send a break of any other duration for us.
+	   This could be changed to use trickery (e.g. lower speed and
+	   send a '\0') to send the break, but for now just return an error.  */
+	__set_errno (EINVAL);
 	return -1;
 	return -1;
+#endif
 }
 }
 #endif
 #endif