FAQ Database Discussion Community


Execute a function in a new process node

node.js,process,fork
I am looking for a way (a npm module or a lib would be really useful) to run a javascript function in a new process. However, I don't want to define this function in a different file. I am looking for something like the POSIX fork mechanism. how can I...

The behavior of the fork() system call on Linux in this code [duplicate]

c,linux,fork
This question already has an answer here: fork() branches more than expected? 3 answers I have read in books and online resources that the fork() system call creates a copy of current process and both the processes start executing from the point after the fork() system call is made....

How do I fork an external process in java

java,process,operating-system,fork
I'm trying to fork a new external process (such as Calculator) in Java. I'm new to operating systems but I learned that it's possible using something like : Runtime.getRuntime ().exec ("C:\\Windows\\system32\\calc.exe");. However that doesn't actually fork a new process. Is there anyway I can fork an external process using java?

Unix - Pipe, forks, execlp, dup2, c program

c,linux,unix,pipe,fork
This is for an assignment. I am new to programming in unix and could use some help. I need to create a C program that does the following: In the main() function, it creates a pipe using the pipe() function, then creates two child processes with fork(). Child 1 redirects...

Forked and executed program does not returns to console

c++,console,exec,fork
I took example program from Advanced Linux Programming site: /*********************************************************************** * Code listing from "Advanced Linux Programming," by CodeSourcery LLC * * Copyright (C) 2001 by New Riders Publishing * * See COPYRIGHT for license information. * ***********************************************************************/ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> /* Spawn a child...

Why is main called twice?

c,fork
I've just learnt about fork, and as I understand it the child process starts execution from the call to fork (otherwise fork would be recursive?). However in this code (ideone link): int main() { printf("%d: Common code1\n", getpid()); if (fork() != 0) { printf("%d: Parent code\n", getpid()); } else {...

Fork() to performe different processes

c,unix,fork,task,children
I'm trying to use the multiple fork() calls to create several children with different task I found a code on Multiple child process Which is really close for what I want , yet I couldn't fully understand it pid_t firstChild, secondChild; firstChild = fork(); if(firstChild != 0) { // In...

Creating non blocking pipes to child that does not block and can be reused

c++,pipe,exec,fork
I am trying to create a inter process communication bus using pipes. I can send messages to the client, and i can receive messages at the client. I also tried to create another pipe which goes the other way, child-> parent. However I need this communication to be non blocking...

fork and pipe confusion from quiz

c,linux,pipe,fork
This is a quiz from my class, and it invovles concept around fork and pipe. I just have a several confusions about this code. 1) What does if((pid = fork() == 0) means? is it just checking fork using pid(process id), why does loop start with this? 2)close (p[1]); what...

Manually set 'forked from' to GitHub project

git,github,fork
My project A (hosted on GitHub) somehow (not sure how) forgot that it was originally forked from another open-source project B. By 'forgot', I mean, when creating a pull request, I cannot choose B as a target for sending the pull request. Is there some way I tell GitHub that...

Infinite Loop with execvp in C

c,shell,fork,infinite-loop,execvp
This program is supposed to be shell which executes commands entered by the user. My program worked fine until I made it accept flags as well as commands. Now, the program loops infinitely at execvp. Any command entered will do this(I've primarily been testing with ls -l). If it matters,...

How do I detect if a system supports forking of processes in python?

python,multiprocessing,fork
How can I figure out if an operating system supports forking like os.fork() without invoking the command itself? I.e. does import os hasattr(os, 'fork') return False under Windows?...

How can I write to a child process stdin obtained with fork() in python?

python,fork
Well, I need to write to stdin of a child process obtained with fork(). I also need to keep the file descriptor(?) of stdin to the parent process for repeating writes to child. I use os.pipe() to get the descriptors, so please keep it this way. pid = fork() if...

fork() in C; which should be parent process which should be child process

c,multiprocessing,fork
This may seem to be a dumb question but I don't really have a good understanding of fork() other than knowing that this is about multi-threading. Child process is like a thread. If a task needs to be processed via fork(), how to correctly assign tasks to parent process and...

Process Emulation

windows,fork,posix,simulation,createprocess
I want to simulate a video process, but I have no much clue about it as the code of process simulation is done by using fork() (POSIX), but now I am going to do it in Windows. Is it ok to use createProcess() ? I just needs some sort of...

How to get return value from a forked / spawned process in Ruby?

ruby,process,output,fork,spawn
My simple test program: pid = Process.spawn("sleep 10;date") How can I place the output (eg stdout) of the "date" command in a variable when it is available? I don't want to use a file for the data exchange....

Wait for all processes reach some point in program, then resume

c,linux,synchronization,fork
I have an application which creates many processes via fork(). At some point I want to pause them all and wait until all of them finish earlier tasks. Then start them all at once. for (int i = 0; i < N; i++) { if(fork() == 0) { //some operations...

Trouble Understanding Fork Logic

process,fork,system-calls
Can someone help me understand what is happening in this segment of code? I am having trouble understanding why the output is how it is. Output is: 0 1 2 3 4 3 2 1 0 int main() { int i; for (i = 0; i < 5 && !fork();...

C, Some statements in fork() not executing

c,process,fork
I think I understand how fork() works, yet only some of my statements in the body execute. For example, in each conversion block, all the printf() will execute yet png_count, gif_count, and bmp_count never increment and remain 0 (as an be seen in the printf() output for child(x); /* Create...

Fork and execlp not executing my program?

c,fork,parent-child,pid,child-process
So I'm trying to create a child using fork and have that child run a program using execlp, only problem is that it isnt running... kind of. Heres my simple program else if (pid == 0) { fprintf(stderr,"Child process is accessing memory %d.\n", rand_num); execlp("helloworld", "helloworld", (char*)0); printf("hi\n"); exit(0); }...

Counter not increasing inside a for using fork()

c,process,fork
I'm working on a little project here and one of the parts requires me to do something if a flag is on and other thing is the flag is off concurrently (using fork()). Althought I know this could bring mutex problems, I cannot seem to get it working. I don't...

Fork creates a new process that is exactly the same as its parent

linux,fork
From the assumption made in the title of my question "Fork create a new process that is exactly the same as its parent". I am wondering how a fork is really made by the operating system. Considering a heavy process (huge RAM footprint) that fork itself to accomplish a small...

What happens if an MPI process crashes?

process,fork,mpi,poco-libraries,fault-tolerance
I am evaluating different multiprocessing libraries for a fault tolerant application. I basically need any process to be allowed to crash without stopping the whole application. I can do it using the fork() system call. The limit here is that the process can be created on the same machine, only....

How to take advantage of each process when using two fork()'s in C

c,process,fork,parent-child
So, I've been trying to understand forks, and although I understand the basics (ie. another process gets created with a copy of the original data when we use fork()), I can't really grasp actually doing things with these processes that are created. For example: I have to write a program...

Understanding why fork gives different result in C

c,linux,output,fork
Although there are some similar questions like this and this I still cannot understand why fork gives different output with the following two codes #include<stdio.h> void main() { printf("Hello World\n"); fork(); } Gives output Hello World Where as this code #include<stdio.h> void main() { printf("Hello World"); fork(); } Gives output...

Memory issue sklearn pairwise_distances calculation

python,out-of-memory,fork,scikit-learn,cosine-similarity
I have a large data frame where its index is movie_id and column headers represent tag_id. Each row is represent movie to tag relevance 639755209030196 691838465332800 \ 46126718359 0.042 0.245 46130382440 0.403 0.3 46151724544 0.032 0.04 Then I do following: data = df.values similarity_matrix = 1 - pairwise_distances(data, data, 'cosine',...

signal handler reading incorrect value

c,signals,fork
on receiving a SIGUSR1 signal, I want to display the value read by the child from the pipe. Having a little issue. It is always displaying 0 despite getppid() was written to pipe by parent process. Any solution? ` #include <stdio.h> #include <unistd.h> #include <signal.h> #include <stdlib.h> char bufP[10], bufC[10];...

How to send a variable between two C programs

c,pipe,exec,fork,argument-passing
I have a C program, xyz.c which does some computations on a certain variable, say transferme. I want to transfer this variable/ pass this variable to another C program, say jkl.c. I have been trying to do the following: Fork the xyz.c and use execvp() to pass this transferme to...

Why does closing a pipe take so long to terminate a child process?

c,pthreads,pipe,fork
I'm having trouble with my program waiting for a child process (gzip) to finish and taking a very long time in doing so. Before it starts waiting it closes the input stream to gzip so this should trigger it to terminate pretty quickly. I've checked the system and gzip isn't...

C, 'fork: resource temporarily unavailable' on TCP server

c,fork,tcpserver
int run () { char str[100]; int listen_fd, comm_fd; struct sockaddr_in servaddr; listen_fd = socket (AF_INET, SOCK_STREAM, 0); bzero (&servaddr, sizeof (servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htons (INADDR_ANY); servaddr.sin_port = htons (8080); int n; bind (listen_fd, (struct sockaddr *) &servaddr, sizeof (servaddr)); listen (listen_fd, 10); int pid; while (1)...

Record and write processes onto a file using C (linux)

c,linux,fork,writetofile
Can someone help me with this small problem please? I am trying to create a fork bomb and record how many processes a computer creates before something weird happens, but I can't figure out how to write the processes into a text file. I looked around the internet and couldn't...

C fork program behaviour explanation

c,unix,fork
I'm completly new to the C language and Unix systems. I might formulate myself badly or wrong. I have a C program where two processes increments a global variable up to 30. I am aware that order of output is random with parallel processing. But when using the | more...

Simple fork and piping

c,linux,pipe,fork
I am trying to understand forking and piping in my operating systems class. I am am not sure why the second child process will not print out the meminfo. It appears to write to the pipe if I print it out, but it will not read anything in the second...

Stuck on wait() after fork()

c,fork,wait
I have looked on some topics about this, but could not solve it - I am forking twice, but when waiting for the last proc it get stuck on wait(), if i remove the wait() it moves on, but obviously it does not wait: here is the relevant code: /*Fork...

How to fork and create a specific number of children that perform the same task?

c,fork,wait
I need to write a C program that calls fork() a given number of times. Each child process needs to perform the same task (adding some random numbers until a given sum is reached). The parent process waits until all of the child processes have exited. I have written the...

GDB and LLDB “swallow” status set by child process in OS X

gdb,fork,osx-yosemite,lldb,sigsegv
Given the following code: #include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/wait.h> int main(int ac, char** av) { int status; pid_t cpid = fork(); if(0 == cpid) { /* Child */ return *(volatile int*) 0; /* exits with signal 11 */ } else { /* Parent */ do { waitpid(cpid,...

fork and exec combination not working if I take some input in child process

python,io,terminal,fork
I wrote a python code in which a process creates another process using fork(). In the child process I want to open another process using execlp(). The program I am opening in the child process shows an EOF error. I don't understand why because when I try to run that...

SIGINT ignored by multiple processes

c,linux,signals,fork,signal-handling
I would like to create three processes, which would print some stuff till I press ctrl+c. Below you can see my try but when a try to stop the program nothing happens. When the only one child is forked, it works good. Where could be a problem? Thanks in advance....

what happens when I exec() from a forked child in c

c,exec,fork
Suppose I have process foo and executable bar. foo calls fork() and now I have two, call them foo_parent and foo_child. foo_parent calls wait() foo_child calls execvp([stuff to run bar]); I don't quite understand what happens to foo_child/bar. Is foo_child overwritten in memory with bar? Is a new bar process...

Interpreting STRACE output - pipes and forks

c,linux,pipe,fork,strace
I have the following code written in C, taken from http://beej.us/guide/bgipc/output/html/multipage/pipes.html: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int pfds[2]; pipe(pfds); if (!fork()) { close(1); /* close normal stdout */ dup(pfds[1]); /* make stdout same as pfds[1] */ close(pfds[0]); /* we don't need this */ execlp("/bin/ls", "ls", NULL);...

Exec after forking a process doesn't return the result before the program finishes

c++,c,pipe,exec,fork
I'm trying to make a program that forks once and while the parent waits for the child terminates, this child forks again and then executes two execs. There is a Pipe on the program and I've checked the return values of every dup2() and pipe() on the program -just omitted...

Why is the output for the id variable 1?

fork
#include <stdio.h> #include <unistd.h> int main() { int id; printf("here comes the date.\n"); if (id = fork() == 0) { printf(“%d”, id); printf ("PID is %d and ID is %d\n", getpid (),id); execl ("/bin/date", "date", 0); } printf ("that was the date.\n"); } OUTPUT: here comes the date. that was...

Segmentation fault 11 printing string from struct

c,string,struct,pipe,fork
This is the first time I've run into Segmentation fault 11 in C and I can't seem to wrap my head around what is actually going wrong. What I'm trying to do is write a few int values to a struct plus the file name from the command line (char...

C++ Fork child, ask child for process list, kill a process in Linux

c++,linux,pipe,fork
I'm trying to create a child process, send the child process a command "LISTALL". The child process should then issue the system the command ps and return that list to the parent process. The parent process should then choose a process and kill it. This is what I have so...

fork() not working as expected

c++,linux,process,fork
I am trying to create a program which spawns two processes -- the first of which monitors the second, and restarts it if it is killed. (The idea is that the only way to kill the second process is to first kill the first.) Below I have code that fails...

Concurrent program in C(sequential issue)

c,linux,concurrency,fork,system-calls
I am trying to find a way to make this algorithm run concurrent and be simultaneous. So far it has only 1 for-loop that reads each file and then makes a process for each file. I believe this algorithm runs sequentially which is not what I want... I thought about...

fork is giving weird output when trying to add variable from child to father after killing child in c

c,arrays,linux,fork
I have this weird problem with a program on which I create 2 processes with a fork(); then i search an array for a specific value entered by the user. in a test version I search for the value 6 in this array. int vet[max]={1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0,6}; so the output is: ci...

Messing with signals, pipes and forks in C

c,bash,shell,signals,fork
How can I get the a process to listen for user input without terminating? . So, for example, i want the bash to wait for X minutes, and if i say "stop" it quits, or else just keeps waiting... How can I achieve that? So, upon execution my process would...

Printing an array in order with fork()

c,fork
i'm trying to print an array with help of fork, where every element will be printed by a seperate child process. void printArray_fork(int *p_array, int length){ int i; pid_t pid; for(i = 0; i<length;i++){ /* Create children procs */ pid = fork(); if(pid==0){ break; } } if(pid == 0) {...

How can I prevent the inheritance of python loggers and handlers during multiprocessing based on fork?

python,logging,multiprocessing,fork
Suppose I configured logging handlers in the main process. The main process spawns some children and due to os.fork() (in Linux) all loggers and handlers are inherited from the main process. In the example below 'Hello World' would be printed 100 times to the console: import multiprocessing as mp import...

signal() in C doesn't work

c,signals,fork
why this code doesn't work? I want that the code print the content of figlioA function if the number in input is even or print another code content in figlioB if the number in input is odd. What is wrong? Thank you! #include <stdlib.h> #include <stdio.h> #include <signal.h> int x;...

why is the total number of processes 2

c,operating-system,fork
I'm trying to figure why do this statement produce 2 processes if(fork()&&(fork()||fork())) printf("Hello"); I understand the short circuiting issue, and I know that if this statement was executed without if we will get 4 processes in total. So can you explain the criteria which is used by inserting if to...

I'm confused how this execvp() is handled in this sample function which uses fork() to clone a process

c++,c,linux,exec,fork
I have the following function from a book titled "Advanced Linux Programming". int spawn (char* program, char** arg_list) { pid_t child_pid; /* Duplicate this process. */ child_pid = fork (); if (child_pid != 0) /* This is the parent process. */ return child_pid; else { /* Now execute PROGRAM, searching...

How to create a child process with a different name

c,linux,process,fork
i'm working with C and i need to create a child process with a different name from father (e.g. child_test) How to do it in Linux with fork()?

Qt app receives HUP signal unexpectedly when forked to background

qt,signals,fork,daemon,signals-slots
I have built a Qt app which upon receipt of the HUP signal shuts down nicely (setup like this how to get signals into Qt). This works great under Red Had 6, but when I run this app under Ubuntu 14 my app receives the HUP signal immediately (after forking...

understanding fork in c

c,fork
#include <stdio.h> int num = 0; int main(int argc, char*argv[]){ printf("common line\n"); printf("%d", num); int pid; pid = fork(); if(pid == 0){ /*child*/ num = 1; } else if(pid > 0){ /*parent*/ num = 2; } printf("%d\n", num); } I above program, common line string is shown single time in...

Linux, forked process hangs immediately

c,linux,fork
I got a problem with fork that only occurs sporadically. It works basically all the time, but fails every once in a while on a test system. My research didn't turn up anybody else mentioning a similar problem. The problem occurs on an embedded Linux system. There is no swap...

Same file descriptor after fork()

fork,file-descriptor,contention
I'm trying to understand what means duplicating a file descriptor after calling fork() and its possible effects on contention. In "The Linux Programming Interface" 24.2.1 (p517): When a fork() is performed, the child receives duplicates of all of the parent's file descriptors. These duplicates are made in the manner of...

How to write/read multiple times to a pipe

c,pipe,fork,ipc
I'm trying to make two child processes communicate with each other via pipe.First child have to write data 1 and data 2, and then second child writes data 3 and data 4. Then childrens read each other data and print them. This is the code that i have so far....

Concurrent programming - Is it necessary to manually lock files that multiple processes will be accessing?

c,concurrency,process,fork
I know for pthreads, if they're modifying the same variables or files, you can use pthread_mutex_lock to prevent simultaneous writes. If I'm using fork() to have multiple processes, which are editing the same file, how can I make sure they're not writing simultaneously to that file? Ideally I'd like to...

Program stuck on Pipe (exec ls grep sort)

c,linux,pipe,fork,dup2
I'm trying to make a program that executes the following commands connecting the output of one to the input of the next using pipes and taking two arguments DIR (directory) and ARG (filetype, example: jpg). ls DIR -laR | grep ARG | sort Here's the code: int main(int argc, char...

fork() bomb explanation in terms of processes? [closed]

linux,operating-system,fork,system,virus
I am just wondering how a fork bomb works, I know that there are similar questions but the answers aren't quite what I am looking for (or maybe I just haven't been able to come across one) How does it work in terms of processes? Do children keep being produced...

Drawing with ncurses, sockets and fork

c,sockets,fork
So I'm doing the barbershop problem but now I want to make it 'visual' and network-friendly. When the server starts up, awaits for clients to connect, each time a client connects it draws a 'P' that travels around the screen up to the barber position. I do this with NCurses...

C Socket/Client fork(), share struct memory

c,sockets,struct,fork,shared-memory
I'm trying to share the memory of a struct on my C server, got the following code // Before the main struct Esami { char nome[20]; char cognome[20]; char matricola[20]; char voto[20]; }; struct Appelli { int stato; char dipartimento[20]; char cdl[20]; char nomeEsame[20]; char data[20]; struct Esami esame[10]; int...

how the fork() function works?

fork,forking
can some one explain this code ? int main ( ){ int i=0 ; while (fork() !=0 && i<2) i=i+1; printf(" this is the process %d and ends with i=%d \n", getpid(), i); return 0; } what I have understand that a process father has 3 children ! but according...

Killing a forked Windows process in Perl

windows,multithreading,perl,fork,kill
I'd like to spawn a process, do something and kill it afterwards manually when I'm done. It's not working though. The process starts, I see the pid and the while loop keeps running until I kill it. Could it be, that Perl spawns a new shell which then spawns the...

How to fork, make significant changes, and give proper credit? [closed]

licensing,elisp,fork
There is an elisp project on github I have forked. Some of the source files and functions I don't want to change, some I want to change drastically, and others only slightly. The original copyright at the top of each source file mentions the project that it came from. 1)...

How do I generate coverage reports for fork()'d children using gcov/lcov?

c,fork,code-coverage,gcov,lcov
I'm having trouble generating coverage reports for a project of mine -- it seems that the lines in the child process after a fork are never hit, althought they clearly are in reality. Here is the coveralls report of the forking part (The results are the same with lcov+genhtml), and...

Multiple pipes and processes

c,operating-system,pipe,fork,child-process
I am trying to communicate with children processes and make them sort a part of a list. My problem is children processes read everything but do nothing after it. int main(int argc, char *argv[]){ int i; int num_children; pid_t pid; num_children= 3; int fd[num_children][2]; //PIPES for (i=0; i<num_children; i++) {...

Composer: Package that extends another from a fork

git,dependencies,fork,composer-php
I've the following situation: There is package author/package1 on GitHub and Packagist. I decided to fork it into tcb13/package1 to add some code (that will eventually get merged into the original project, however it will take time). Later on, I developed another package, tcb13/package1-extension that extends the fork tcb13/package1 by...

How to tell if child Node.js Process was from fork() or not?

javascript,node.js,process,fork
I have a small application that could be executed by a fork or directly by a developer, and I would for it to get configured slightly differently depending on how it was started. I know that I could always pass in arguments to to signal that it was a fork,...

correct output for this fork concept in C

c,output,fork,atoi
So for some reason I can't get the output of this code in C, so I can only ask a few conceptual question on this code below: What does int N = atoi(argv[i]); do? is it just define integer N as an array? In the for loop, what does if...

pipe can not read/write all the chars

c++,linux,ubuntu,pipe,fork
I am trying to send array of char from one process to another using pipe, the characters are passing but not all of them! only the part of the beginning. This is my code: int p1[2], p2[2]; int main() { pipe(p1); int f1= fork(); if(f1 == 0) { char ar[100];...

Fork() cannot be called from a Device Driver in linux

c,linux,kernel,fork,device-driver
So, I'm writing this driver wich recieves a "command" via "write" and it is supposed to call fork and let the child finish the job while the parent dies. When I compile it the output is this. [email protected]:~/Área de Trabalho/mc504-linux/linux-3.17.2$ make -j 5 ARCH=i386 CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h...

program stuck on wait()

c++,debugging,unix,fork,wait
I'm having an issue with a process being stuck on wait. I've been troubleshooting this issue and its the only bug i have currently for my shell program. The problem is the program should exit when the user enters "exit". However it seems if the user enters an invalid string...

Pipes, child processes, and the scope of a child process

c,unix,concurrency,pipe,fork
I am in an Operating Systems class and I have a project that deals with forks and pipes. I'm trying to understand forks and pipes a little better before I get started on my project, so I was working through an example. This is the code in question (case 0...

GITHUB: How to convert forked repository that was turned standalone back t a fork

git,github,repository,fork
I have a github fork that was turned standalone after the main repository changed from private to public. According to github documentation, if a private repository is made public, each of its private forks is turned into a standalone private repository and becomes the parent of its own new repository...

redirect unnamed pipe output to log file in c

c,pipe,fork,dup2
i want to redirect the output of an unnamed pipe to an opened log file in c but i can't seem to make it happen, my code looks like this: close(fildes[1]); FILE * file = fopen(logfile, "w"); int fd = fileno(file); if (fd == -1) { bail_out(EXIT_FAILURE, strerror(errno)); } /*...

why does fork() return all possible outputs in this combination?

c,output,fork,child-process
Question: I need clarification/help on my understanding of fork() outputs. I know how to program more detailed and larger code in c with fork() and use other concepts like pipe, ipc, threads(posix). But my understanding with predicting return output is bad which is why I'm trying to figure this out...

How to accurately kill child process after certain time limit in C?

c,linux,unix,process,fork
I've been attempting to write a program that can accurately kill a forked process after the child exceeds a certain running time. The process should be spawned from an executable on the disk. I am using linux, here. Let's not even consider the ugliness of simply forking a process on...

Fork and child/parent processes

c,fork
I'm studying for a midterm for my OS class and was looking at this code example. On my system (OS X Yosemite) I'm getting ONE TWO FOUR TWO THREE, so it seems like the child process runs and outputs first before the parent does, despite the lack of a wait()...

Avoid variable duplication using fork() in C

c,multithreading,sockets,fork,shared-memory
I am implementing a server that serves multiple clients and I need some server's variable to be in shared memory so a client actually sees what another client has eventually edited. I tried looking around but I didn't understand if there is any way to achieve this by using fork()...

C - Creating two processes which obtains 50 unique integers

c,process,operating-system,fork
So I am trying to figure out the logic for this homework assignment. Can someone help? From what I understand I have to create 2 processes which reads the N from the given file and increment that N number by 1. The part I don't understand is how I assign...

C pipes write/read priority

c,pipe,fork
I am trying to understand pipes and the use of fork in C. Below is an example of a code that calls fork() and then: Child process: Reads the pipe and prints the content to console. Parent process: Writes in the pipe "hello world". int main(void) { pid_t pid; int...

fork() understanding, about execution and children

unix,parallel-processing,fork
I'm just starting to fork() and I'm having some difficulties understanding the parallel execution. I've found this example code and I want to know if the first time it will go true or false (I know if pid1==0 it means it's a child, etc). I also want to know how...

Shared Memory UNIX Segmentation Fault (fork()) in C++

c++,unix,segmentation-fault,fork,shared-memory
I have a problem with shared memory and processes. I attach an area to the shared memory, I make a child proccess but when I try to modify the shared memory area in the father process I only get segmentation fault, it just can be modified in the child. .h...

Pyramid, fork, Java and sockets

java,python,sockets,fork,pyramid
A complicated situation: A Pyramid app needs to start/restart some Java processes (e.g. Jetty) sometimes (e.g. on receiving new WAR files for Jetty, etc, etc). That Jetty process is expected to continue working after Pyramid process (pserve) quits or between Pyramid restarts. Jetty process is started via subprocess.Popen + shell...

unable to use fork() in recursion? [closed]

c,linux,recursion,fork
I have got programming assignment to merge to arrays using binary insertion search(ie., in sorted order) using fork() system call in C in linux based OS. I have done it WITHOUT using fork() and its working fine. Now I want to use fork() system call in it. I have read...