Skip to content
Advertisement

Why only the parent process takes input?

I created a program that forks and asks for input:

JavaScript

I run it and enter one number:

JavaScript

Why does it appear that only the original parent process gets a number? Why isn’t the output instead e.g.:

JavaScript

Advertisement

Answer

All of the processes accept input. The problem is that only one can do so at a time. Which process is getting the input at any given time is unpredictable.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement