'I wonder if sleep() affects fork()
your text
int main(void) {
if (fork()) {
// 1. sleep(1);
printf("parent");
}
else {
// 2. sleep(1)
printf("child");
}
}
l know sleep() and fork() ,But I confuse about sleep and fork()
1.What happens if first sleep is executed and second sleep is not executed? 2. also , What happens if second sleep is executed and first sleep is not executed?
As I expected, first question -> childparent and second question -> parentchild
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
