hi monks can any one tell me weather the child process will be killed after executing client process completely.
#!/usr/bin/perl use Socket; use Carp; use IO::Handle; my $port = 4573; $|=1; # Setup some variables my %AGI; my $tests = 0; my $fail = 0; my $pass = 0; my $capture = 0; sub checkresult { my ($res) = @_; my $retval; $tests++; chomp $res; if ($res =~ /^200/) { $res =~ /result=(-?\d+)/; if (!length($1)) { print STDERR "FAIL ($res)\n"; $fail++; } else { print STDERR "PASS ($1)\n"; $capture = $1; print STDERR "capture is $capture"; $pass++; } } else { print STDERR "FAIL (unexpected result '$res')\n"; $fail++; } } socket(SERVER, PF_INET, SOCK_STREAM, 0); setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); bind(SERVER, sockaddr_in($port, INADDR_ANY)) || die("can't bind\n"); listen(SERVER, SOMAXCONN); for(;;) { my $raddr = accept(CLIENT, SERVER); my ($s, $p) = sockaddr_in($raddr); $child = fork(); if ( ! $child ) { CLIENT->autoflush(1); while(<CLIENT>) { chomp; last unless length($_); if (/^agi_(\w+)\:\s+(.*)$/) { $AGI{$1} = $2; } } print STDERR "AGI Environment Dump from $s:$p --\n"; foreach my $i (sort keys %AGI) { print STDERR " -- $i = $AGI{$i}\n"; } print CLIENT "GET DATA /demo-congrats \"\"\n"; my $result = <CLIENT>; print STDERR "result is $result"; &checkresult($result); if($capture==1){ print STDERR "Going to ask to play tt-monkeys"; print CLIENT "GET DATA tt-monkeys \"\"\n"; my $result = <CLIENT>; &checkresult($result); } elsif($capture==2){ print STDERR "Going to ask to play demo-congrats"; print CLIENT "GET DATA demo-instruct \"\"\n"; my $result = <CLIENT>; &checkresult($result); } else{ print STDERR "In else condition"; } print STDERR "================== Complete ==================== +==\n"; print STDERR "$tests tests completed, $pass passed, $fail fail +ed\n"; print STDERR "================================================ +==\n"; close(CLIENT); exit(); #kill (9, $child); } close(SERVER); }
Actually i have created a socket program with one socket and more than one client by using fork function and i would like to know weather the child process will be terminated after executing it completely. So, can any one give me suggestions on this code. Thanks in advance.

In reply to Reg socket by sanku

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.