Похожие чаты

Any idea why is it possible to write to stdin

using write function in C and this can write chars to screen ?

7 ответов

7 просмотров

https://stackoverflow.com/questions/37822580/why-is-it-possible-to-write-to-stdin A quick search on Google would answer most of your questions

Abdo- Автор вопроса

i found that one , i didn't understood it very well

Abdo
i found that one , i didn't understood it very wel...

Give me some time. I will explain that a little more clearly; though I still think that SO answer does explain it well.

Abdo- Автор вопроса
Abdo
i found that one , i didn't understood it very wel...

You have to understand a bit of history on serial devices to be able to understand what the answer in SO is saying. In olden days, when you needed to use a computer (typically a mainframe computer) located away from the place you would be sitting at, you used to have a terminal device (a keyboard and a monitor). This communication was done using serial communication (this was preferred over a parallel communication because of the ease of implementation and cost savings. It saved on the number of wires used for communication). The serial communication required setting of things like baud rate (how many bits are sent every second), whether the communication channel was duplex or simplex (imem whether there can be communication from either end at the same time or whether it was always one at a time), agree on start bits (the bits used to indicate when data transfer is to begin from an idle channel) and stop bits (bits used to indicate when a data transfer has ended and that the channel is transitioning to idle state) and so on. During those days, most communication was one way that only the terminal device or the mainframe could be communicating at any point of time. Because of this, the serial devices were configured to support both input and output at the same time, rather than having two different channels (one configured for input and the other configured for output). Since a device could only be either transmitting data or receiving data at any point of time (because of hardware restrictions), opening them for both input and output at the same time was not a problem. So the kernel would typically open a channel for both input and output and then duplicate these channels as input stream, output stream and error stream and pass them on to login and shell. This behavior has been replicated in modern kernels for compatibility reasons and hence you can write to stdin which would then echo the characters on to the terminal device. In modern kernels, if you redirect the stdin to a regular file, output will fail however. The compatibility is retained only when input is pointed to a terminal or a terminal emulator.

Your question is my answer to something lol

Abdo- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Is Kadena onto something special? No one really knows. Good luck!
Bright Uncle Stephen EqualBet
40
А кто-то пробовал, уезжая из Эстонии получить э-рез и продолжить вести предпринимательскую деятельность внутри Эстонии, используя свой OÜ?
Lalalashechki Lalala
62
здравствуйте. совершаю вот такую вещь: strcpy(line, (char)current_number); где current number — неподписанный шорт, line — массив чаров. ругань следующая: main.c:29:30: error...
Roberto's Ширгозиев
13
Гайз, кто-нибудь пробовал запустить probe-rs под камень, которого нет в probe-rs? Мб есть какой-нибудь пример у кого... Через target-gen попробовал сгенерировать chip-descript...
Максим Смирнов
1
Всем привет. Ребят подскажите пожалуйста. Вопрос по дизасемблировани. Начну с начала. У меня есть скомпилированная программа на ГО (я разработчик) - в ней есть защита лицензии...
Zloy
11
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
isn't utxo commitements pretty close though if someone wanted to get it over the finish line? my understanding is that most of the ground work was already down by verde
Luke High - Rabbi Of Bcash High Rabbi Of Bcash
23
@MrMiscipitlick А можешь макрос написать, который будет вычислять смещение относительно переданных меток? Просто .label1-.label2, и вернуть значение.
КТ315
35
А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
is the buyback program live and at what prices are the purchases fixed? excuse me for the bland PA question, sophisticated defi people keke
Imnothere
20
Карта сайта