Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!rice!sun-spots-request From: polstra!jdp@uunet.uu.net (John Polstra) Newsgroups: comp.sys.sun Subject: Re: stty problem Keywords: Miscellaneous Message-ID: <3289@brazos.Rice.edu> Date: 22 Nov 89 01:53:17 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 62 Approved: Sun-Spots@rice.edu X-Refs: Original: v8n192, Replies: v8n198 X-Sun-Spots-Digest: Volume 8, Issue 207, message 6 of 16 In article <3081@brazos.Rice.edu> mhickey@sherwood.prime.com (Mark E. Hickey x4149 x4417 ) writes: >X-Sun-Spots-Digest: Volume 8, Issue 198, message 11 of 18 > >>I can't seem to alter the options of /dev/ttya or /dev/ttyb on my SPARC >>station 1. The command I use is >> >> stty parodd cs8 > /dev/ttya >> >> [results of this command failing deleted] >> >> What am I doing wrong? > >Just out of curiousity, I looked into this problem on our SPARCstation 1 >(run- ning 4.0.3). I found that the device must be turned on in the file >/etc/ttytab (ie: the fourth field of the entry for ttya must read "on"); >by default it is turned off. Also, if you turn the port on while the >system is running, you must tell init to re-read the file by sending it >SIGHUP (eg: kill -1 1 on most systems, do a "ps -eax | grep init" to be >sure of the process id). If the port is turned off, getty apparently >resets the parameters no matter what you set them to using stty ... Good guess, but that's not what is going on. When you do an "stty" under Unix, the new modes stick only as long as the tty port is held open (by one or more processes). When the last process closes the tty, the modes revert to some kernel-defined default. You can see this by comparing the effects of the following two lines: stty parodd cs8 >/dev/ttya; stty everything >/dev/ttya (stty parodd cs8; stty everything) >/dev/ttya In the first line, the tty gets closed between the two "stty" commands, and the second "stty" will show the default modes regardless of what was set by the first "stty". In the second line, the tty is held open from the beginning of the first "stty" through the end of the second "stty". Here, the second "stty" will show the modes as set by the first "stty". If you mark a tty as "on" in "/etc/ttytab", then "getty" will hold that tty open all the time. Then, any "stty" that you do will stick. This has the unfortunate side-effect that any incoming characters on the tty will be swallowed by "getty". If you want to change the tty modes for a single command (e.g., "foo"), the easiest way is like this: (stty parodd cs8; foo) >/dev/ttya If you want to change the modes more-or-less permanently, this trick will work: sleep 100000000 >/dev/ttya & stty parodd cs8 >/dev/ttya The "sleep" just holds the tty open for a few years, so that subsequent "stty" commands will stick. John Polstra jdp@polstra.UUCP Polstra & Co., Inc. ...{uunet,sun}!practic!polstra!jdp Seattle, WA (206) 932-6482