Sponsored Content
Full Discussion: IPC-using fork() in a loop
Top Forums Programming IPC-using fork() in a loop Post 302450045 by saman_glorious on Wednesday 1st of September 2010 11:11:53 AM
Old 09-01-2010
I tried it both on CentOS 5.2 and Ubuntu

plz have a look at my code again

Code:
   for(int count = 0; count < nIntClientCount; count++)
   {
      pid_t pid;

      if((pid = fork()) < 0){
          perror("fork failed\n");
            exit(1);
      }else if(pid == 0)
      {
         if((pid = fork()) < 0)
         {
                          perror("inner fork failed\n");
                                exit(1);
         }
         else if(pid > 0)
                exit(0);
          //second child body

            printf("I am CHILD %d\n", count);
            fflush(stdout);
      }
     if(waitpid(pid, NULL, 0) != pid)
        perror("wait pid didn't match\n");
   }

  printf("parent exited..\n");

  return 0;
}


Last edited by pludi; 09-01-2010 at 12:42 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

fork() and IPC

Hey all. I recently ported a multithreaded program from WinNT to LINUX using pthreads. Everything works fine, except that it turns out the drivers for the hardware I'm working with aren't thread safe. So, now I have to find a way to make this multi-process instead of multi-threaded. I just... (1 Reply)
Discussion started by: TelePlayer
1 Replies

2. Shell Programming and Scripting

Endless loop - Fork function failed?

I need a quick script that will serve as a sort of "real time monitor" for watching some log files. I am using Bourne shell in HP-UX 10.20. I have basically created a script that never ends, unless of course I manually terminate it. Here's the script (it's called qhistory): clear echo "REAL... (3 Replies)
Discussion started by: cdunavent
3 Replies

3. Programming

fork() in for loop

hello, Every time i use fork() in the for loop, my college network(which i work in) either gets slow or hangs up.Can any 1 explain why it is so? Of course there is no use of doing it though. But still i want to clear my doubt. Thanks (2 Replies)
Discussion started by: cyno
2 Replies

4. UNIX for Dummies Questions & Answers

Ipc

I have a parent that is passing data to child A and then child A has to process it and pass to child B. I am able to pass the data to child A but am not able to pass it to child B. Child B seems to only be receiving the last data instead of the whole data. I saw one example in a book but it uses... (1 Reply)
Discussion started by: scmay
1 Replies

5. UNIX for Dummies Questions & Answers

Ipc Details

hai, i am doing my masters degree in computers.please any one tell me about fork(),semaphores,mutex,messaging queues,messaging using pipes ,and msgget(),msgrecv() funtions in ipc programming . i have exam on that i have a book but in that they not given clearly. hope u will ... (2 Replies)
Discussion started by: G.Vishnuvardhan
2 Replies

6. Programming

[C] Problem with IPC

Hi! I'm trying to write this program: in my intentions it should get a message and send it to a second process (pid_upost), then to a third process (pid1, pid2, pid3, depending on the choice made when a new message is inserted). This program should write the message in a file (message1, message2 or... (1 Reply)
Discussion started by: Kaminski
1 Replies

7. Solaris

errors on Netra-440: "IPC Warning: ipc: tcp_protocol: bad magic number"

I was asked to look into a problem with a Sun Netra 440 in another department. On the server in question, the relevant 'uname -a' information is, "SunOS host1 5.9 Generic_118558-16 sun4u sparc SUNW,Netra-440". That information aside, while the other admin is logged into the ALOM, these errors are... (0 Replies)
Discussion started by: Borealis
0 Replies

8. Shell Programming and Scripting

Inifinite Loop on fork

I am trying to ping through a list of devices in parallel. When the code below is executed, I enter a infinite loop. I want to used the number of lines in the file as my boundry. I am a perl rookie and just cant see whats wrong. would appreciate help ... use Net::Ping; # $filename... (0 Replies)
Discussion started by: popeye
0 Replies

9. Programming

C Socket Client/Server Fork Loop

Hello people. I'm trying to do something like a search engine. Server runs in the background by using ./server & which has data from a textfile stored in an array. Client then runs by using ./client It will then prompt "Search for:" For example, if I searched for Products called Instant... (0 Replies)
Discussion started by: andylbh
0 Replies

10. HP-UX

IPC settings on HP-UX

Hi Experts, Need your help for checking te interprocess communications settings on HP-UX box. Using ipcs command I am able to view Message queue,semapohores etc, but from that output I m not able to understand how to determine if there is any issue with ipc settings and how to resolve that? (1 Reply)
Discussion started by: sai_2507
1 Replies
YAFARAY(1)																YAFARAY(1)

NAME
yafaray - Yet Another Free RAYtracer DESCRIPTION
yafaray [options] file_to_render DESCRIPTION
yafaray is an advanced raytracing rendering systems that accepts an XML input file and produces an image output file based on its contents. OPTIONS
-s strategy Use strategy to render the scene, where strategy is either threaded (fork multiple threads, which is the default), mono (use a single thread and process), or fork (fork multiple processes). fork is not implemented yet. -c N Use N processes or threads (depends on the strategy), for operating on an SMP computer or cluster. -r min_x:max_x:min_y:max_y Render only part of the frame, values between -1 and 1. The whole image is -r -1:1:-1:1. -z Optimize for running on a cluster by gzipping some data passed between processes. -p path Set an alternative path for the plugins. -v Show the program version. SEE ALSO
See the documentation on the website for more information <http://www.yafaray.org/>. AUTHOR
This manual page was written by Nick Rusnov <nickrusnov@debian.org> for the Debian system (and may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. 2011-07-20 YAFARAY(1)
All times are GMT -4. The time now is 09:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy