We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,267 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Problem with muliple fork calls - PERL script

Hi All,

In my script, i am trying to call multiple fork call.

if i call less than 10 times, its working fine.

If i call more than 20 or 30 times, most of the process getting time out or died

foreach my $ttyport (@processTTY)
{

    my $pid = fork();Inline Code Example Here


    ..............
    ..............
    ..............

}

Can somebody suggest the solution for this issue?

`

2
Contributors
1
Reply
3 Weeks
Discussion Span
2 Months Ago
Last Updated
15
Views
cacofonix
Newbie Poster
7 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

consider this fragment:
Youll see that the $ttyport is not a global variable,
each fork call gets its own copy, so its gonna loop more than
expected.

#!/usr/bin/perl

use POSIX;


for($i = 0; $i < 10; $i++){

  $pid = fork();
  if($pid){

   $ppid = getppid();
   print "$ppid\n" unless $ppid == 1;
  }


}
coding101
Junior Poster in Training
74 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0578 seconds using 2.69MB