Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/rfcomm_sppd only modify the termios structure when t...
details: https://anonhg.NetBSD.org/src/rev/e888efedea05
branches: trunk
changeset: 767433:e888efedea05
user: plunky <plunky%NetBSD.org@localhost>
date: Mon Jul 18 15:44:17 2011 +0000
description:
only modify the termios structure when tty_in is verifiably a terminal
diffstat:
usr.bin/rfcomm_sppd/rfcomm_sppd.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diffs (48 lines):
diff -r b10e7d75cd52 -r e888efedea05 usr.bin/rfcomm_sppd/rfcomm_sppd.c
--- a/usr.bin/rfcomm_sppd/rfcomm_sppd.c Mon Jul 18 14:11:27 2011 +0000
+++ b/usr.bin/rfcomm_sppd/rfcomm_sppd.c Mon Jul 18 15:44:17 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rfcomm_sppd.c,v 1.13 2010/11/03 08:27:27 plunky Exp $ */
+/* $NetBSD: rfcomm_sppd.c,v 1.14 2011/07/18 15:44:17 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -62,7 +62,7 @@
Copyright (c) 2006 Itronix, Inc.\
Copyright (c) 2003 Maksim Yevmenkin m_evmenkin%yahoo.com@localhost.\
All rights reserved.");
-__RCSID("$NetBSD: rfcomm_sppd.c,v 1.13 2010/11/03 08:27:27 plunky Exp $");
+__RCSID("$NetBSD: rfcomm_sppd.c,v 1.14 2011/07/18 15:44:17 plunky Exp $");
#include <sys/param.h>
@@ -230,18 +230,20 @@
* be used directly with stdio
*/
if (tty == NULL) {
- if (tcgetattr(tty_in, &t) < 0)
- err(EXIT_FAILURE, "tcgetattr");
+ if (isatty(tty_in)) {
+ if (tcgetattr(tty_in, &t) < 0)
+ err(EXIT_FAILURE, "tcgetattr");
- memcpy(&tio, &t, sizeof(tio));
- t.c_lflag &= ~(ECHO | ICANON);
- t.c_iflag &= ~(ICRNL);
+ memcpy(&tio, &t, sizeof(tio));
+ t.c_lflag &= ~(ECHO | ICANON);
+ t.c_iflag &= ~(ICRNL);
- if (memcmp(&tio, &t, sizeof(tio))) {
- if (tcsetattr(tty_in, TCSANOW, &t) < 0)
- err(EXIT_FAILURE, "tcsetattr");
+ if (memcmp(&tio, &t, sizeof(tio))) {
+ if (tcsetattr(tty_in, TCSANOW, &t) < 0)
+ err(EXIT_FAILURE, "tcsetattr");
- atexit(reset_tio);
+ atexit(reset_tio);
+ }
}
} else {
if (daemon(0, 0) < 0)
Home |
Main Index |
Thread Index |
Old Index