10 More Discussions You Might Find Interesting
1. Programming
Hi friends,
I have a small question regarding unix system call fork, I hope you will solve my problem. Here is the small program
$ cat fork1.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
int pid;
int x = 0;
x = x + 1;
pid = fork();
if(pid < 0)
{... (2 Replies)
Discussion started by: gabam
2 Replies
2. Programming
Greetings everyone, I need a bit of help in solving the following problem:
I'm given an array of numbers and I have to compute the sum of the array elements using n processes, and the inter process communication has to be done with pipes(one pipe, to be exact).
I managed to solve the problem... (14 Replies)
Discussion started by: ephesos
14 Replies
3. Programming
Assume you have such a piece of (more or less pseudo-)code:
if(fork() == 0) {// childprocess
chmod(someProgram, 00777);
exec(someProgram);
} else { // assume it never fails and this is the parent
chmod(someProgram, 00000); // should be executed as soon as possible after the... (5 Replies)
Discussion started by: disaster
5 Replies
4. Programming
Hi gurus can you explain following lines of code ?
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(void)
{
pid_t pid;
int rv;
switch(pid = fork()) {
case -1:
... (7 Replies)
Discussion started by: wakatana
7 Replies
5. Shell Programming and Scripting
Hello,
I am trying to create a pipe that will direct stdout to in side of the pipe, and stdin to the out side of the pipe - I created two child processes to handle this. However, my pipe doesn't seem to be working correctly. Did I use execv() correctly? Command1 and command2 represent the two... (3 Replies)
Discussion started by: jre247
3 Replies
6. Programming
Hi everyone , after a pipe() system call i've forked and entred into the child process to execve a shell script .the problem here is that when the execve sys call fail , i want to send the error code (eg errno) to the parent process using the pipe writer side p , there is nothing received in the... (4 Replies)
Discussion started by: xtremejames183
4 Replies
7. UNIX for Advanced & Expert Users
Hi, as I understand fork(), it makes a copy of the parent which becomes a child. But is there anyway to make three children for that one parent. So in other words, if I look up the getppid() of the children, I want them to have the same value??
Thanks in advance to any help! (1 Reply)
Discussion started by: MS_CC
1 Replies
8. Programming
Hello, I'm trying to implement a version of a bucketSort (kinda) server/client, but I'm having a VERY hard time on making the server behave correctly, when talking to the children, after it forks.
The server is kinda big (300+ lines), so I won't post it here, but here's what I'm doing.
1)create a... (8 Replies)
Discussion started by: Zarnick
8 Replies
9. Programming
I know how to read and write if i have a forked process with only one child. However what is involved with reading and writing with many forked processes. Say one parent that forks 5 children, and needs to communicate with all 5 in half duplex.
int temp, counter=0;
do{
pipe(temp);
... (5 Replies)
Discussion started by: steveneliuk
5 Replies
10. Programming
hi there, im trying to produce this program that would run at first, and when it runs it will fork one child process to a program and then another forking to run this other program, and then another one .
i cant seem to get it right can someone help me please here is what is got so far:
int... (1 Reply)
Discussion started by: zmanultra
1 Replies