my $PID; BEGIN { $PID = getpid(); } SIG{TERM} = sub __set_semaphor { open my $sema, '>', "$PID.semaphor"; print $sema 1; close $sema; return 1; }; # bei Terminierung hier Aufräumen, später Dateien etc schließen, was weiß ich was du noch machst... sub __cleanup { my $self = shift; sleep(10); unlink "$PID.semaphor"; 1; } sub process { my $self = shift; my($cmd, @args); my $sock = $self->{SOCK}; while(my $line = <$sock>) { # check for termination semaphore if ( open my $sema, '<', "$PID.semaphor") { my $terminated = <$sema>; if ($terminated =~ /^1/) { $self->_put("451 4.7.1 Service unavailable - try again later;"); $self->__cleanup(); exit(255); # end client } } $Net::SMTP::Server::Client::DEBUG and print STDOUT $line; # Clean up. chomp $line; $line =~ s/^\s+//; $line =~ s/\s+$//; if (!length $line) { $self->_put("500 Learn to type!"); next; } ($cmd, @args) = split(/\s+/,$line); $cmd =~ tr/a-z/A-Z/; if( !defined $_cmds{$cmd} ) { $self->_put("500 Learn to type!"); next; } return(defined($self->{MSG}) ? 1 : 0) unless &{$_cmds{$cmd}}($self, \@args); } return undef; }