Skip to content

Tag: operating-system

Why only the parent process takes input?

I created a program that forks and asks for input: I run it and enter one number: Why does it appear that only the original parent process gets a number? Why isn’t the output instead e.g.: Answer All of the processes accept input. The problem is that only one can do so at a time. Which process is gettin…

How atomic the fork() syscall actually is?

Assuming check_if_pid_exists(pid) returns true when a process with such a pid exists (but possibly hasn’t been running yet) or false when there is no process with such pid, is there any chance in parent code for a race condition when the fork() returned the child pid, however the kernel hasn’t had…

How to reproduce the accept error in Linux

I’m learning Unix Network Programming Volume 1, I want to reproduce the accept error for RST in Linux. server: call socket(), bind(), listen(), and sleep(10) client: call socket(), connect(), setsockopt() of LINGER, close() and return server: call accept() I think that the 3rd steps will get an error li…