All Questions
2,053
questions
1
vote
0
answers
46
views
CSAPP 3e (global): Possible erratum for "Practice Problem 8.3" (p. 781)?
Due to the relative lack of popularity of CSAPP's global edition, I have been unable to figure out whether exercise problem 8.3 (partial screenshots shown above) is entirely correct. I have only found ...
1
vote
0
answers
48
views
from where the child process will get informations about other variables that are before the fork()?
in my case i have a code where there are mentioned many fork() (8 times) functions so many child processes are going to be created , so let's imagine the every fork() is related to its variable like ...
0
votes
1
answer
52
views
In Linux (POSIX), how to forward stdin to forked child process while inspect the content?
I'm developing a command line application to hijack the invocation of CLI tools like ls or cat. I need to inspect and analyze the original stdin content passed to them. However, I found it quite ...
0
votes
0
answers
28
views
Can't focus and bring process window to foreground with PID
I'm writing a program that would focus on the process window and bring it to the foreground given the process PID. I've came up with the following program in C, but it doesn't always work despite the ...
1
vote
1
answer
69
views
How to read/inspect variables of a binary at runtime?
Let's say we compile a C program (with debugging symbols) into a binary and run it. We now want to know the state of the variables inside of the process while it is running.
The most straight forward ...
0
votes
1
answer
53
views
How do I get my signal handler to catch a signal sent by a child process?
I'm writing a very basic shell in C with some basic job control. If the user enters a non-built in command, then the parent forks and creates a child then the child can execute a program.
I have ...
0
votes
0
answers
34
views
libproc only showing one mapped region [duplicate]
I've got this MRE compiled on macOS:
#include <stdio.h>
#include <unistd.h>
#include <libproc.h>
int
main()
{
int ret, num;
struct proc_regionwithpathinfo info[20];
...
1
vote
1
answer
38
views
How does the child process signal completion of execution?
Here is the host program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <wait.h>
int main(int argc,...
0
votes
1
answer
44
views
Which child will execute first when you call fork() and wait() multiple times?
When you call fork() multiple times, and then call wait(); which child will be executed first? The first, or second child?
int main(int ac, char **av, char **env)
{
t_d f;
static int ii;
...
0
votes
0
answers
28
views
Strange output in a synchronization problem using binary semaphores in C
Recently i came across this exercise that for some reason always gives me strange output, here is the code followed by an output example:
HERE'S THE CONSUMER PROCESS
#include <stdio.h>
#include &...
4
votes
1
answer
76
views
Global pointer appearing null to signal handler
I have some C code that launches processes. For each process it registers some metadata in a linked list of structs. Then, the SIGCHLD handler updates said metadata. The structure is something like ...
1
vote
1
answer
64
views
Kill child process when execvp fails in C function
I have a function in C that creates a child process and uses execvp() to execute a certain task.
pid_t pid = fork();
if (pid == 0) {
if (execvp(cmd->arg_array[0], cmd->arg_array) == -1) {
...
1
vote
2
answers
85
views
Creating a fork causing fgets to reread a file infinitely
I'm trying to write a program that reads through a bunch of Unix commands, and creates child processes to execute them. It has one argument that determines the maximum number of child processes I want ...
-1
votes
1
answer
120
views
Reading lines from a file redirected to stdin in multiple processes using fgets
I'm trying to make a c program that creates several processes, based on an argument, and then has them all start reading lines from stdin and then do things with them (for now I'm just printing them ...
0
votes
0
answers
89
views
How to create more than 1 child process with a loop?
How can I create an efficient loop that lets 2 child processes work with 2 different files?
I tried using a loop like:
for(i = 0; i < 2; i++){
if((pids[i] = fork()) < 0){
fprintf(...