I really need your help. I have studied and read a lot of information about this. But still don't understand anything. I cannot get it for a long time. SO I hope someone can help to understand this stuff.I think that I also don't understand what is really tty, in my view it is virtual devices that is used as abstraction layer between user input/output and kernel of linux , these devices are sending info to system using ioctl interface. And it sending back output. This is required only when communicating with kernel directly sending requests. GUI in turn in some way break out from terminal (I don't know how, please explain) and doesn't interact with you using pseudo devices.
Am I correct ?
I am interesting in how can I run backround tasks from terminal, as using ampersand (&) in shells. I have read that this functions helps to do this. But I don't understand how.
What is the purpose of this functions.
tcsetattr - set the parameters associated with the terminal
What is a terminal in this case ? It is /dev/tty devices ? There are three open file STDIN , STDOUT , STERR ? Or whatever ?
Here is definition
int tcsetattr(int fildes, int optional_actions,
const struct termios *termios_p)
What is fildes parameter refers to ?
The tcsetattr() function sets the parameters associated with the terminal referred to by the open file descriptor fildes
Which descriptor ? Descriptor of opened process file /dev/tty . For example I have four opened files for bash 0 1 2 255. As I can guess 255 is filedescriptor of tty devices ?Okey , but how does 0 1 2 connected to user input/output, if we have opened dev/tty which handles requests. Is this files are connected to this /dev/tty (255) pseudo device ?
Why this should be useful when I am going to fork and send forked process in background ?? What should I do to put process in background ? As I can guess I need to close or open new 0 1 2 file for this process in order not to write in parent input ?? OR I am completely wrong. What is the correct way to send process into background , but not completely lose control of it ? I have read about tcsetpgrp , I understood. The first process connected to the dev/tty devices will be its leader.So terminal group will have same id as the first process ? Am I correct ?
And finally why do we need all this tty now, earlier it was the way of remote connection to computer. But why not to call system (kernel) functions directly ?
I have lack of comprehension... I really need someone help. I WOULD BE VERY GRATEFUL FOR ANY HELP. Please explain for such stupid like.