Using Pipes and Named Pipes to get your programs working together.
HTML-код
- Опубликовано: 12 июн 2024
- Patreon ➤ / jacobsorber
Courses ➤ jacobsorber.thinkific.com
Website ➤ www.jacobsorber.com
---
Do you want one of your computer programs to talk to another? Let's look at one of the most basic ways to make this happen, with pipes.
***
Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
More about me and what I do:
people.cs.clemson.edu/~jsorber/
persist.cs.clemson.edu/
***
Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
More about me and what I do:
www.jacobsorber.com
people.cs.clemson.edu/~jsorber/
persist.cs.clemson.edu/
To Support the Channel:
+ like, subscribe, spread the word
+ contribute via Patreon --- [ / jacobsorber ]
+ rep the channel with nerdy merch --- [teespring.com/stores/jacob-so...]
Source code is also available to Patreon supporters. --- [jsorber-youtube-source.heroku...]
Want me to review your code?
Email the code to js.reviews.code@gmail.com. Code should be simple and in one of the following languages: C, C++, python, java, ruby. You must be the author of the code and have rights to post it. Please include the following statement in your email: "I attest that this is my code, and I hereby give Jacob Sorber the right to use, review, post, comment on, and modify this code on his videos."
You can also find more info about code reviews here.
• I want to review your ...
The little kiddo in the background - so sweet! Another great video!!
I love the invasion of the kids at 3:30
Indeed.
வாழ்க வளமுடன்!
Disgusting.
@@robertkiestov3734 lol
I first thought that it was a dog, perhaps an en.wikipedia.org/wiki/Afghan_Hound.
i love how you show the practical implementation instead of just talking about the concept in an abstract way .Thank u sm for your videos .After 5 years still very helpfull
One of the best channel on C programming and programmation with process, awesome
Thanks.
lmao the dude crawling in the back
looking forward to sockets. glad to see you back
Thank you for this great video and other videos. They are truly phenomenal, they make pipes and bunch of other things a lot easier to understand.
Agreed, he's my goto to find things out. Search him now before SO etc to see if he has anything.
I really wish I found your channel ages ago lmao In the past couple of months, I'll probe the videos you've put out and there seems to always be a video on what I'm currently trying to implement 😂 Currently have a logging library that I'm working on but didn't know how to handle if a user pipes console output elsewhere and this video gave me some much needed insight, so thank you again!
That's what I'm here for. 😀 But, seriously, thanks for letting me know. It's always great to hear that this stuff is making a difference to someone.
Love this guy
Thank you for returning
We saw it 😂
And thank you!
Great job
Amazing video subbed
kickass video loved it
Tks a lot my friend!
You're welcome. Glad you enjoyed it.
awesome video!!!! !!!!
3:30 the hostage has escaped
Yes, indeed. She does that sometimes.
@@JacobSorber lol
So a named pipe is basically a file which only exists in RAM? And therefor will be lost at reboot? And it can only be opened for writing by one process at a time?
Any example code of using asynchronous named pipes, both for client and server, in C++ (or even in C) ? I'm searching for hours, cannot find anything understandable.
Great video! Can you make a video about how to use Unix domain socket?
It's on my list. Hopefully in the coming months.
Few views, but this is actually the explanation easiest to understand
Thanks. Yeah, I keep waiting for this named pipe video to go viral. I'm glad you enjoyed it.
What happens if the process receiving the input from the pipe isn't as fast as the process that is feeding the pipe? I assume that eventually you'll run out of memory?
Good idea for another "what if" video. I think the pipe's buffer will fill up, and the process putting data into the pipe will block until the process reading from the pipe catches up and makes space. But, you should try it out.
Looking at recent Linux kernel code, it looks like its done like following:
- If the pipe writer opens the pipe nonblocking (see man page open), then the kernel will return -EAGAIN
elixir.bootlin.com/linux/v5.15.31/source/fs/pipe.c#L551
Your application is responsible of handling that -EAGAIN, basically you would try again to write.
- If the pipe writer opens the file in blocking mode, wants to write into the pipe, but the pipe is full, then the kernel will put this process to sleep.
elixir.bootlin.com/linux/v5.15.31/source/fs/pipe.c#L570
Your application should block
I want to know the editor you are using in this video, thanks.
I think I used atom on this one. I have used both atom and VS Code in most of my videos.
Nice easter egg at 3:33 - random family member pops up!
is mynamedpipe also a buffer?
If you type in "grep Chrome" you can see how it works! Type in a few lines and one with Chrome in it. (Ctrl+c) will exit.
0:00
It's been a long time,
Rakim the microphone soloist
Can you make a video about the pipe function?
As you wish. ruclips.net/video/8AXEHrQTf3I/видео.html
👍👍👍
the guy in the backround lol
Who's peeking at 3:24?
My daughter. Apparently, she had left something in the room and didn't want to wait for me to finish recording.
One more thing: stderr is unbuffered
good but too fast!! please take a bit more time!!
I've tried to improve my pacing over the years. Are the newer videos working better for you, pace-wise?
@@JacobSorber yes! I surely like your content!
Way too fast
Channel is good but you are going too fast.
Thanks, and sorry about that. I'm still trying to figure out the right pacing. Fortunately, you can play videos back at reduced speed. Hopefully that helps.
@@JacobSorber Thats issue is minor as my exams is soon and prepare for operating system hope you give us more content
Especially the ego part is fantastic; just love it.
@@JacobSorber The fast tempo is a feature. But a few seconds more to be able to stop the video at a right time would be beneficial.
How is pipe different from entering another parameter in the command line. For example, this works:
cat logfile.log | cantools plot dbcfile.dbc
(or in windows type logfile.log | cantools plot dbcfile.dbc)
Yet the following won't work
cantools plot dbcfile.dbc logfile.log
Presumably because cantools is using the filename as the data rather than the contents in the file? Is it possible to even use a tool like 'cantools plot' without Pipeing?
How would one programmatically call this exe with arguments (plot dbcfile.db) while piping the data (cat or type)?