What is waitpid?
HTML-код
- Опубликовано: 7 янв 2021
- Source code can be found here:
code-vault.net/lesson/cq9yhdt...
===== Support us through our store =====
code-vault.net/shop
===== Check out our website =====
code-vault.net
===== Check out our Discord server =====
discord.code-vault.net
You helped me in 15 minutes with two videos to understand what my professor couldnt explain me in 2 hours. Thank you!
Yaaay back to the unix processes. My favourite 2 serieses unix threads and unix processes. Thx keep going. You're the beast 😘
Thanks for this great lecture! Intiailly I worried the double fork() might compllcate things, but then I realized that the return value inside each child makes the branch looks like " ----/---/----/ ".
I got the job.
Congratulations!
@@CodeVault thank you sir. One step towards my dream. One day I will be programming for Elon Musk 😅😅.
@@bsgamer5069 what kind of job brother? Due to this tutorial? Than its great congrats...
@@SureshKumar-dt1sl I got the job as a programmer mostly backend using c# mostly.
Thank you for the video! I have another question because you mentioned at the beginning that this is possible with child processes. If I use waitpid with different processes, such as MPI processes, can I still use it? (to wait for MPI processes) Signals, etc. also work without the process needing to be a child.
waitpid only works on a child process (from the docs linux.die.net/man/2/waitpid
Hey I am having a small issue while trying out your programs on visual studio code, the sys/wait library isn't showing up. Is this library available for Windows or do I have to install linux for this?
It's only for Linux. You might be able to get this running using WSL
THANK YOU THANK YOU THANK YOU!
hi tony
Hey Toni
@@jordangunn2851 Hey Jordan lol
Only the calling thread is waiting on the process? So if I have the main thread and create a new thread before fork and waitpid. That newly created thread keeps executing and isn't influenced by the main thread calling waitpid on the forked process. Is this correct? I'm trying to implement waitpid myself on system level and I'm not completely sure about this.
waitpid only makes the caller wait for a child process to stop executing. Also, if you actually mean threads instead of processes then waitpid would wait on both threads if it's called on both threads. If it's just a child process, since it doesn't have any, it will simply return
@@CodeVault thanks👍🏼
do u have anything about Competitor Access in C
?
I'm not sure what you mean exactly. Can you send my some links or an example?
didnt get the 2nd fork() because its its not in the father block of code i mean both father and child will execute it this will lead to 4 childs instead of 3 ?
The child process won't execute the 2nd fork() simply because there is a return statement in its if block (so it just exits before it gets to the fork() statement)
@@CodeVault got it thank you
Can you make film about termios?
Seems very specific, I'll see what I can do
Спасибо за содержательные уроки !)
What behavior when not executioning wait() then end child process then executed wait(). so wait() will wait for non-existent process. How to prevent this case. i need help
Yes. wait() does wait for non-existent processes since it also releases any resources related to that process, that's why it's recommended to always wait for the child processes to finish their execution (note: modern OSes do clear resources even if wait() is not called). You can check if the process hasn't finished execution by adding the flag WNOHANG to waitpid but not the other way around.
What is the use-case for this?
I am totally different results on macos :(
Seems like on MacOS the WNOHANG option doesn't exist for waitpid. Otherwise, everything works the same. Just replace WNOHANG with 0, although the calls will no longer return immediately
Here's the documentation: developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/waitpid.2.html