You summarized my 4 two-hour operating system classes in 4 minutes. Thanks
@thiagoalexandrenakao907111 күн бұрын
Dude, i think you forgot to use the close function. On the the father, before writing you should close the read file descriptor of the father. After writing, you should also close the write descriptor of the father. This tells to the kernel that the father does not need to listen or write anymore, saving resources. Also, you should close the the write file descriptor of the child process before reading, and close the read file descriptor after finishing.
@lucasschneider-dev Жыл бұрын
Stumbling upon your channel is one of the greatest things that happened to me in 2023. Keep up the great work! Also, can you do one on grep? XD
@nirlichtman Жыл бұрын
Thanks :) Yes, grep is a good idea, very powerful and useful command
@phatboislym Жыл бұрын
mind blown, hopefully one day I'll actually understand stuff like this
@nirlichtman Жыл бұрын
Pipe is an example of a Linux system call which is a service that the operating system provides that applications can call, for example there are also system calls for opening files and writing to files and much more. Check out my video about Linux System Calls for a more basic example.
@phatboislym Жыл бұрын
@@nirlichtman oh, I mostly understand that part it's the actual low-level magic in the code I don't get
@nirlichtman Жыл бұрын
@@phatboislym what specific part of the code? I can help explain
@abzrg4 ай бұрын
I imagine the pipe as a file in which I can write into via fd[1] and I can get stuff out of with fd[0]. In the diagram at the beginning of this video, the first hello on the left is going into the pipe via fd[0] and the second one coming out of the pipe via fd[0]. I hope that's correct. btw: why did you open the pipe before creating the fork? I understand that both will have the same copy of fd array (at different memory space), but why not declaring fd afterwards?
@Jonathan-ru9zl4 ай бұрын
After line 12, when the parent and child split and after return, is it possible to get back to the parent process?
@tankman1301 Жыл бұрын
Well, I thought I know pipes. Almost didn't watch the video. Turns out I didn't
@yaSSeraitnaSSer6 ай бұрын
question : what happens when the parent process dies first? does it not create a zombie process? and if so how did the program work after killing the parent process? thank you for the content sir keep it up!
@abzrg4 ай бұрын
yes the process will be a zombie process and it will have its ppid set to init system's pid. I think SIGKILL won't affect it and resources are not returned until the process is finished.
@yaSSeraitnaSSer4 ай бұрын
thank u @@abzrg , i eventually got the exact same answer, thank u again
@pandorian79 ай бұрын
your content is just amazing! =
@DragonSlayer227406 ай бұрын
writing code in vim is so difficult - big respect
@not_kode_kun3 ай бұрын
it just has a steep learning curve compared to other editors, but once you get used to it you'll never want to go back. at least not to regular keybindings. Like, if I'm one day forced to use something like vscode for work, I'll definitely install the vim keybindings extension. Now that I know how to use vim, I don't ever want to go back to writing text the normal way. It's just extremely slow. You should definitely give it a shot. Trust me, if you stick with it for even a few days, you'll already be competent enough to never want to go back.
@joehayden60654 ай бұрын
Sick af. Great explanation.
@navdeepladdha17752 ай бұрын
Amazing explanation in less time 🫡🙏
@cheesus228910 ай бұрын
Perfect explanation!
@Bearded_Dragon_Sir Жыл бұрын
I'm watching these videos in the background while I do other things lol
@jasdfff7707 ай бұрын
How would this work on Windows?
@not_kode_kun3 ай бұрын
it wouldn't, windows isn't POSIX-compliant. Nir is on windows here but he's doing all that on wsl, so he still gets that POSIX functionality. If you want to do this natively on windows, the code would look a lot different and you'd be using the windows api, not the C standard library, since it's built specifically with POSIX in mind.