summaryrefslogtreecommitdiff
path: root/src/stty.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-02-10 18:30:08 +0000
committerJim Meyering <jim@meyering.net>1994-02-10 18:30:08 +0000
commit589f6b1c17d8fe77d001d3ef8a0b40c748073f1a (patch)
tree0575a849e5cb92ba57e25ab5db206fe2c1ffc3cc /src/stty.c
parenta751e875624617d6e615d5d42ec370ae654ff3e7 (diff)
downloadcoreutils-589f6b1c17d8fe77d001d3ef8a0b40c748073f1a.tar.xz
CIBAUD hack for SunOS 4.1.x
Diffstat (limited to 'src/stty.c')
-rw-r--r--src/stty.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/stty.c b/src/stty.c
index ea75cc18a..45fc52ad4 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -107,6 +107,7 @@
/* SunOS 5.3 loses (^Z doesn't work) if `swtch' is the same as `susp'.
So the default is to disable `swtch.' */
#if defined (__sparc__) && defined (__svr4__)
+#undef CSWTCH
#define CSWTCH _POSIX_VDISABLE
#endif
@@ -632,10 +633,10 @@ main (argc, argv)
char **argv;
{
struct termios mode;
- struct termios new_mode;
enum output_type output_type = changed;
int optc;
int require_set_attr;
+ int speed_was_set;
program_name = argv[0];
opterr = 0;
@@ -691,6 +692,7 @@ done:;
exit (0);
}
+ speed_was_set = 0;
require_set_attr = 0;
while (optind < argc)
{
@@ -747,6 +749,7 @@ done:;
}
++optind;
set_speed (input_speed, argv[optind], &mode);
+ speed_was_set = 1;
require_set_attr = 1;
}
else if (!strcmp (argv[optind], "ospeed"))
@@ -758,6 +761,7 @@ done:;
}
++optind;
set_speed (output_speed, argv[optind], &mode);
+ speed_was_set = 1;
require_set_attr = 1;
}
#ifdef TIOCGWINSZ
@@ -803,6 +807,7 @@ done:;
else if (string_to_baud (argv[optind]) != (speed_t) -1)
{
set_speed (both_speeds, argv[optind], &mode);
+ speed_was_set = 1;
require_set_attr = 1;
}
else
@@ -820,6 +825,8 @@ done:;
if (require_set_attr)
{
+ struct termios new_mode;
+
if (tcsetattr (0, TCSADRAIN, &mode))
error (1, errno, "standard input");
@@ -844,8 +851,23 @@ done:;
and not all systems have the same fields in this structure. */
if (memcmp (&mode, &new_mode, sizeof (mode)) != 0)
- error (1, 0,
+ {
+#ifdef CIBAUD
+ /* SunOS 4.1.3 (at least) has the problem that after this sequence,
+ tcgetattr(&m1); tcsetattr(&m1); tcgetattr(&m2);
+ sometimes (m1 != m2). The only difference is in the four bits
+ of the c_cflag field corresponding to the baud rate. To save
+ Sun users a little confusion, don't report an error if this
+ happens. But suppress the error only if we haven't tried to
+ set the baud rate explicitly -- otherwise we'd never give an
+ error for a true failure to set the baud rate. */
+
+ new_mode.c_cflag &= (~CIBAUD);
+ if (speed_was_set || memcmp (&mode, &new_mode, sizeof (mode)) != 0)
+#endif
+ error (1, 0,
"standard input: unable to perform all requested operations");
+ }
}
exit (0);