Leser: 2
2 Einträge, 1 Seite |
1
2
3
4
5
6
7
sub sigchldHandler {
while (0 < (my $child = wait())) {
print STDOUT2 "closed Child: ".$child."\n";
}
}
$SIG{CHLD} = \&sigchldHandler;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
while($conn = $Net::SMTP::Server::server->accept())
{
# Wenn eine Verbindung durch einen Client aufgebaut wurde wird der SMTP-Server geforked
my $kidpid = fork();
if (not defined $kidpid)
{
die "Cannot fork: $!";
} elsif ($kidpid == 0)
{
# fork gab Null zurück, also ist dies hier das "Neugeborene"
# die Abarbeitung beginnt
print STDOUT "Kindprozess: ".$$."\n";
my $client;
$Net::SMTP::Server::Client::client = new Net::SMTP::Server::Client($conn) ||
croak(getTime()." Unable to handle client connection: $!\n");
$Net::SMTP::Server::Client::client->process();
$from = $Net::SMTP::Server::Client::client->{FROM};
@to = $Net::SMTP::Server::Client::client->{TO};
$msg = "blubb";
$msg = decode_qp($msg);
@mail = split(/\n/,$msg);
# Convert a Mail::Internet object to a MIME::Entity:
$parser->output_under("/tmp");
$parser->decode_bodies(0);
$entity = new MIME::Entity;
$entity = $parser->parse_data($msg);
exit(0);
}else{
print STDOUT "Vaterprozess: ".$$."\n";
}
}
1
2
3
4
linux:~/forwarder# ./Mailer.pl
Kindprozess: 28551
Vaterprozess: 28549
closed Child: 28551
$SIG{CHLD} = 'IGNORE';
QuoteOn most Unix platforms, the "CHLD" (sometimes also known as "CLD") signal has special behavior with
respect to a value of 'IGNORE'. Setting $SIG{CHLD} to 'IGNORE' on such a platform has the effect of
not creating zombie processes when the parent process fails to "wait()" on its child processes (i.e.
child processes are automatically reaped). Calling "wait()" with $SIG{CHLD} set to 'IGNORE' usually
returns "-1" on such platforms.
2 Einträge, 1 Seite |