Тёмный

What happens when you type a command in the terminal? 

Carl Tashian
Подписаться 143
Просмотров 6 тыс.
50% 1

To answer this question, I wrote a tiny "sh.py" shell in Python that simulates the core function of Bash, which is to provide an environment where we can run programs based on commands typed.

Наука

Опубликовано:

 

16 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 12   
@jsagar1987
@jsagar1987 2 года назад
Underrated in terms of likes. Really worth it for all the details you shared flawlessly.
@ship2nip
@ship2nip 6 лет назад
great video !! thanks a lot for posting this
@GaneshManika
@GaneshManika 3 года назад
Nice. Thank you!!
@DHARMiLSANGHVI
@DHARMiLSANGHVI 3 года назад
Amazing video ! Can you please tell me what terminal is this that you are using?
@PurnachandMedisetty
@PurnachandMedisetty 2 года назад
do parent and child processes both write to the same fd1,fd2 concurrently? sorry, not an expert here. let me ask that little differently after exec() and replacing current shell program with some other program like echo with args "foo" echo writes $1 to stdout. so do I start to see "foo" getting displayed on terminal right here even before child exits?
@tashian
@tashian 2 года назад
Yeah! Try it and see. Both programs will have the same fd0, 1, and 2. One thing bash handles is redirection, by modifying the file descriptors for the child before exec() is called.
@_AnuragsinghThakur
@_AnuragsinghThakur Месяц назад
ah aha ah aha aha ahahahahahaahha
@sweetness583
@sweetness583 Год назад
Why does fork() create a copy of the currently running process? That seems unnecessary.
@tashian
@tashian Год назад
What do you mean by unnecessary?
@sweetness583
@sweetness583 Год назад
@@tashian Why wouldn't the computer just reserve memory for the program and then run it? What if you were running a big process and need to call a simple one? It's going to copy the whole process first? That seems wasteful.
@tashian
@tashian Год назад
@@sweetness583 It's a great question. Forking a process is efficient and requires very few resources, due to the way memory management works on most computers. Look up "copy-on-write memory management" for more details.
@sweetness583
@sweetness583 Год назад
@@tashian Oh ok. Thanks, I will look that up.
Далее
Bash Scripting 4 -- How Bash Scripts Work
12:00
Просмотров 64 тыс.
Shell Program Explained
31:57
Просмотров 31 тыс.
Shell Code-- More Detail
53:00
Просмотров 10 тыс.
How to execute another program in C (using exec)
14:23
Просмотров 103 тыс.
Смело ставь iOS 18
0:57
Просмотров 92 тыс.
Собери ПК и Получи 10,000₽
1:00
Просмотров 2,7 млн