mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-29 08:08:37 +00:00
stty fails with a non-obvious error message if it's run on a non-tty
stream, such as a rsh or vi pipeline. The error message is: stty: TIOCGETD: Operation not supported It's immediately obvious to the knowledgable hacker type, but not exactly comforting to the user who's not native to unix. It's especially confusing if there's a stty command in their .cshrc and it's showing up on rsh output. (Fixes PR #bin/573) Submitted by: peter@haywire.dialix.com (Peter Wemm)
This commit is contained in:
parent
d700586c3a
commit
37712f2a7b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9384
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: stty.c,v 1.3 1995/04/29 15:00:34 bde Exp $
|
||||
* $Id: stty.c,v 1.4 1995/05/30 00:07:28 rgrimes Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -95,10 +95,12 @@ main(argc, argv)
|
||||
args: argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (tcgetattr(i.fd, &i.t) < 0) {
|
||||
warn("tcgetattr: not running on a terminal");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
|
||||
err(1, "TIOCGETD");
|
||||
if (tcgetattr(i.fd, &i.t) < 0)
|
||||
err(1, "tcgetattr");
|
||||
if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
|
||||
warn("TIOCGWINSZ: %s\n", strerror(errno));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user