Joseph K. Myers
Friday, April 16, 2004
On the computer I use, I often am in Finder of one mode, but almost all of my work is in Terminal in other modes and on other computers.
My general-purpose mode is "myerskid," because all of the children can use it, and any kind of user switching is really just a pain. In consequence of doing this, I find that having a non-Administrator mode (like myerskid) for Finder is really the most clever, flexible way of doing things, without having to do any user switching at all. (A password can unlock items in System Preferences, and I can log into my mode from Terminal, since all that I do there is on terminal, anyway. It had been a year since I had logged into my own mode on Finder, until something had to be deleted by someone who didn't know how to do it on Terminal.)
A few days ago I "had" to restart the computer because without watching I let all of the ttys run up to ttywf. I knew that I should have known a way to fix it, but of course I am practical and turning off the computer isn't so much against my scruples that I wouldn't do it.
(For example, I won't fool with cookies so that I can find the sixth chemical on chemfinder.com. Instead, I go to the next computer and in a very legitimate way I proceed--although to buy a second computer solely for the purpose of not having cookies prevent you from searching more than five times is very inefficent, it is the absolute most effective technique when I am sitting next to an open computer at school.)
I'll describe the problem with this scenario.
As usual, I'm in myerskid, and I open Terminal and login jmyers.
I logout. I quit Terminal. (Any program that is open will waste the CPU. If it weren't for this Macbeth "damn spot" on the system, a program should never be closed.)
Next time I open Terminal, I'm on ttyp1, for example, if I started with ttyp0.
This continues until I am on ttywf, and then I'm out of using any terminal, either on X11 or in Terminal (except for console, which uses /dev/console as it's tty, and thankfully was lucky to not be created by Apple to have this kind of duck soup problem). Any attempt to use the Terminal application results in a message "Completed Command."
Now it might take 19 days or so for me to run out of ttys, but I still need to know how to fix them.
Looking after I restarted at the ttys in /dev/tty*, I found things like this:
a) Emtpy ttys I haven't used:
... crw-rw-rw- 1 root wheel 4, 24 Apr 10 16:07 /dev/ttyq8 crw-rw-rw- 1 root wheel 4, 25 Apr 10 16:07 /dev/ttyq9 crw-rw-rw- 1 root wheel 4, 26 Apr 10 16:07 /dev/ttyqa crw-rw-rw- 1 root wheel 4, 27 Apr 10 16:07 /dev/ttyqb crw-rw-rw- 1 root wheel 4, 28 Apr 10 16:07 /dev/ttyqc crw-rw-rw- 1 root wheel 4, 29 Apr 10 16:07 /dev/ttyqd crw-rw-rw- 1 root wheel 4, 30 Apr 10 16:07 /dev/ttyqe crw-rw-rw- 1 root wheel 4, 31 Apr 10 16:07 /dev/ttyqf crw-rw-rw- 1 root wheel 4, 32 Apr 10 16:07 /dev/ttyr0 ...
Also, the earlier ones which have been used:
crw-rw-rw- 1 root wheel 2, 0 Apr 16 16:35 /dev/tty crw-rw-rw- 1 root wheel 8, 0 Apr 10 16:12 /dev/tty.irda crw-rw-rw- 1 root wheel 8, 2 Apr 10 16:12 /dev/tty.modem crw--w---- 1 root tty 4, 0 Apr 10 16:07 /dev/ttyp0 crw--w---- 1 jmyers tty 4, 1 Apr 16 16:35 /dev/ttyp1 crw-rw-rw- 1 root tty 4, 2 Apr 10 17:03 /dev/ttyp2 crw-rw-rw- 1 root tty 4, 3 Apr 10 19:48 /dev/ttyp3 crw-rw-rw- 1 root tty 4, 4 Apr 11 09:25 /dev/ttyp4 crw-rw-rw- 1 root tty 4, 5 Apr 11 12:39 /dev/ttyp5 crw-rw-rw- 1 root tty 4, 6 Apr 11 23:22 /dev/ttyp6 crw-rw-rw- 1 root tty 4, 7 Apr 12 21:32 /dev/ttyp7 crw-rw-rw- 1 root tty 4, 8 Apr 13 13:44 /dev/ttyp8 crw-rw-rw- 1 root tty 4, 9 Apr 13 13:44 /dev/ttyp9 crw-rw-rw- 1 root tty 4, 10 Apr 13 17:47 /dev/ttypa crw-rw-rw- 1 root tty 4, 11 Apr 13 19:17 /dev/ttypb crw-rw-rw- 1 root tty 4, 12 Apr 13 20:31 /dev/ttypc crw-rw-rw- 1 root tty 4, 13 Apr 14 20:11 /dev/ttypd crw-rw-rw- 1 root tty 4, 14 Apr 14 21:53 /dev/ttype crw-rw-rw- 1 root tty 4, 15 Apr 16 15:28 /dev/ttypf crw--w---- 1 jmyers tty 4, 16 Apr 16 16:24 /dev/ttyq0 crw--w---- 1 jmyers tty 4, 17 Apr 16 16:25 /dev/ttyq1 crw-rw-rw- 1 root wheel 4, 18 Apr 10 16:07 /dev/ttyq2 ...
Obviously, I can see that right now (after I have just reset all the ttys from p1 to pf), I am logged in onto ttyp1 on the Terminal in myerskid, but since also on this Terminal tty session I have logged into jmyers, ttyp1 says it is owned by jmyers and writable by jmyers, and all of that clears out myerskid from using it again.
The solution is to take a lot of old ttys owned by jmyers and other people (but not really used by them any more) and do:
sudo -s chown root [ttys] chmod 666 [ttys]
This restores them to a state like
crw-rw-rw- 1 root tty 4, 2 Apr 10 17:03 /dev/ttyp2
where they can be used again by a different user than the one which last had them.
Solution:
6-17-04: Insert the following into ~/.bash_logout.
chmod 666 `tty`
http://www.myersdaily.org/joseph/problems/ttywf.txt