TLDR: You have to close the write end of all pipes in all children. The read will detect EOF only if no process has the write end still open. Credits to @Bodo As part of an assignment for an operating systems course, I’m trying to read lines from a file which is in the format of x operand y and
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 getting the
Computing the set of writes when executing a function
I want to write a function computeWriteSet that takes an arbitrary function f as an argument and (1) executes the function f and (2) returns the set of places modified or written to (addresses/pages/objects) during f’s execution. What options exist for implementing it? What are their tradeoffs (in which case which implementation is more efficient and what are the limitations?)
How can i use a pre installed Intellij Idea that was installed on Windows 7 now on linux?
I have a pre-installed IntelliJ IDEA 2018 with all my code running on it on Windows 7. I want to somehow use the same version of the installation instead of reinstalling the software again on linux and setting up all the libraries and the paths to my code again. Is there a way that i can use that installation of
How to wait() only for some child processes and prevent zombies
I’m trying to write a mock-shell in c on linux, and got stuck on this problem: I need to run some processes in the background, and some processes in the foreground. To prevent the foreground processes from becoming zombies, I can use wait(), but how do I prevent the background processes from becoming zombies? Answer You cannot prevent any process
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 a chance to initialize the data structures so that
How do the clock function works in operating systems?
I don’t understand how clock function works within an operating system. First the documentation for clock function in www.cplusplus.com is: As far as I understand, the clock function must access directly some register within the CPU that is a counter for CPU cycles. How is this possible? I mean, any register of 32 bits would overflow very soon if it
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 like ECONNABORTED, but not. Do I want to know why? I will
GDB: breakpoint in linux built-in module fails
I am debugging linux kernel using two virtual machines connected via serial port. Target machine awaits connection from remote gdb, by inserting kgdbwait() and kgdboc=ttyS0,115200 in the correct entry in /boot/grub/grub.cfg. In Host machine Symbols are read and I am supposed to be able to put breakpoints on function names. Works fine! However, if I set a breakpoint at htb_dequeue_tree
In a system call are hardware and software context saved?
Who saves the hardware and software context before the system call routine? Is it the processor itself or the software handler? Thanks. Answer Each system call has a wrapper function as already mentioned, each wrapper function triggers interrupt 128, int 0x80, which automatically saves on kernel stack the registers eip, esp, cs, ss, eflags. In the handling function a SAVE_ALL