FAQ Database Discussion Community


Race condition with setpgid

c,linux,posix,pid,forking
While working on a program for my OS class, I discovered an interesting case involving a what appears to be a race condition involving setpgid. Compile each program below separately. After executing ./test 3 (or any number > 2), ps jx will show that all of the infy processes have...

Parallel-ForkManager, DBI. Faster than before forking, but still too slow

performance,perl,dbi,forking
I have a very simple task on updating database. my $pm = new Parallel::ForkManager(15); for my $line (@lines){ my $pid = $pm->start and next; my $dbh2 = $dbh->clone(); my $sth2 = $dbh2->prepare("update db1 set field1=? where field2 =?"); my ($field1, $field2) = very_slow_subroutine(); $sth2->execute($field1,$field2); $pm->finish; } $pm->wait_all_children; I could just...

Do we need a server to fork a Git repository?

git,forking
Forking on Github or Bitcket creates a repo's copy under your own account. Does this mean that forking is a server-side action? I was unable to find "fork command" inside Git. If it's not a server-side action, what are the steps to fork a local Git repository with full history...

Github: forking loop

git,github,forking
I'm still very new to coding and Github and as such am a little confused with how forking repos works - so please forgive what may be a basic question. I've been working on a project with different pair partners all week and my current code base situation is as...

Unexpected output with fork() [duplicate]

c,unix,process,output,forking
This question already has an answer here: printf anomaly after “fork()” 3 answers I read somewhere that in Unix, after fork() is executed successfully, both processes will start their execution at the next statement following the fork() call. Meanwhile when I run this code in C #include <stdio.h> 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...

Value of first element in 2D string array being changed unexpectedly after forking

c,arrays,string,forking
I am writing a shell that handles piping. I get the user input and split it into segments according to what pipes, if any, are input and put it into an array. The first item in the array is the number of elements in the array stored as a string....

python forked processes not executing with os.execlp

python,osx,exec,forking
I've got this simple python script that ought to fork new processes and then have each execute a command using os.execlp, but the execution only occurs once. I'm curious if there's a timing issue going on that is preventing the additional forks from executing: import os for n in range(5):...

C synchronize processes using signal

c,linux,signals,system-calls,forking
Okay so I am trying to teach myself on how to do signalling, and I came across a hiccup and I can't figure out what I'm doing wrong. What is going on right now is: it is executing the parent then goes to child and then back to parent.. It's...