What does fork() actually return?

preview_player
Показать описание
Source code can be found here:

===== Support us through our store =====

===== Check out our website =====

===== Check out our Discord server =====
Рекомендации по теме
Комментарии
Автор

Hey! I’m glad you’re back, your channel has some of the best C explanations i’ve seen on Youtube, thank you for everything you do!

nythepegasus
Автор

So happy to see a new video from you! Amazing content - I hope you’ve been well.

JakeLuden
Автор

I'm doing 42 school and your videos are fire man. I recommend them to other students whenever I can. Thank you for the amazing work you're doing! I'm so happy to see you again, to see that you're all fine and healthy. I can see in the comment that I'm not the only one ;)

lorisp
Автор

So glad you are back! Your video series helps me a lot!

alectonz
Автор

I had this question but now I understand it clearly! Thank you very much!

obscuredbyclouds
Автор

Atlast you are back, Thank You Sir providing amazing content.

animeshsarkar
Автор

Nice, happy to see ya making videos again

thefossenjoyer
Автор

🤗
so good to see you again...
Another great explanation

attituderecord
Автор

ubb computer science students said thank you sir

mateicojo
Автор

@CodeVault when a child is created it will have all lines of code that is below the fork() statement right?
but here fork() is assigned to id and its in the same line . so how does child id gets value 0?
if the child gets all the set values from parent then the id should be +ve ???

abhijitarun
Автор

Child process continues from the the fork statement,
and what happens to memory is also interesting.
The child gets a copy of all the set values by the parent. Unless the variables are a pointers.
Is that correct?

vilijanac
Автор

could you pls explain why this code prints 4 times hello ?

int main() {
int pid, pid2;
pid = fork();
if (pid){
pid2 = fork();
printf("hello");
}
else {
printf("hello");
pid2 = fork();
}
return 0;
}

tendulkarzone