1.)
Yes, although there is more to it. ttys000
is also a character device sitting in /dev
, a user that has permissions to write to the tty
group (most users have) can pipe characters into that device and they will appear on the corresponding terminal. ttys*
are not real teletypes though, they're emulated tty
s, emulated by your (appropriately named) terminal emulator.
I do not have a Mac so I'll use the Linux naming convention for the following example:
Open terminal A as user A and find the emulated tty:
[userA@terminalA]$ tty
/dev/pts/0
Open terminal B as user B and do the same:
[userB@terminalB]$ tty
/dev/pts/3
Now redirect a couple of characters from terminal A to terminal B:
[userA@terminalA]$ echo Hi there > /dev/pts/3
And see them appear on terminal B:
[userB@terminalB]$ Hi there
On a Mac the devices should be /dev/ttys*
, I believe.
2.)
More or less. The ttys000
itself is just the character device, the actual entity that is controlling your java process is the terminal emulator. By controlling I mean that it is the parent off your java process. The parent can interact with its children in an easier fashion than other processes can.
Moreover, if certain precautions are not taken (see man nohup
for an example of such precaution), the death of the parent process will cause the death of all its children processes.
3)
The answer by Karlson already explain that the ?
means a process not associated with a terminal.
Since the terminal itself is just the character device, I believe it is not hard to conclude that it is not necessary for a process to be associated with a terminal device.
Closing notes
The actual terminals /dev/tty
are hardly used on modern *nix OSes (although they're used ensively during the boot process). But that does not mean you cannot use the actual terminals. On a Linux machine (sorry, I have no clue how a Mac performs this) the combination Ctrl + Alt + F1 (and F2, F3, ... up to F7) gives you a real terminal. One of these real terminals is used to perform the graphical display.
Several processes (including graphical applications) on a modern *nix OS are associated with a terminal device because the script that starts them needs to pass extra arguments. The script fires a shell passes the extra arguments and starts the process. Such scripts are often causes for confusion.