Skip to content
Advertisement

Tag: fork

read() hangs on zombie process

I have a while loop that reads data from a child process using blocking I/O by redirecting stdout of the child process to the parent process. Normally, as soon as the child process exits, a blocking read() in this case will return since the pipe that is read from is closed by the child process. Now I have a case

fork: child process doesn’t stay in an infinite loop

In the above code snippet inside if statement if we put while(1), it doesn’t remains blocked and when enter key is pressed program is exited, but in case of parent if we put while(1), parent remains blocked until we give ctrl+c. Please clarify this behaviour of child. Answer In the above code snippet inside if statement if we put while(1),

Change child process’ termination signal at runtime

Using clone() to fork a process you can specify the signal a child process should send its parent on death instead the “normal” SIGCHLD. Is it possible to change the set termination signal after the child was created? Either by the child or the parent? Answer I (quickly) scanned Linux’ source for assignments to struct task_struct’s member exit_signal. This seems

Can someone please explain how this works?fork(),sleep()

What is happening here? How is sleep() getting executed in the for loop? When is it getting called? Here is the output: Please explain this output. I am not able to understand how it’s working. Step by step analysis would be great. Answer In the first loop, the original (parent) process forks 10 copies of itself. Each of these child

Why is sys_fork not used by glibc’s implementation of fork?

In eglibc’s nptl/sysdeps/unix/sysv/linux/i386/fork.c there’s a definition: which is used in actual __libc_fork() as the heart of the implementation. But e.g. in Linux’s arch/x86/entry/syscalls/syscall_32.tbl exists a sys_fork entry, as well as in syscalls_64.tbl. So apparently Linux does have its special syscall for fork. So I now wonder: why does glibc implement fork() in terms of clone, if the kernel already provides

Advertisement