2004-06-28 05:05:03 +02:00
|
|
|
#!/usr/bin/perl -Tw
|
2010-04-08 07:30:30 +02:00
|
|
|
# Copyright (c) 2001-2010 Ask Bjoern Hansen. See the LICENSE file for details.
|
2004-03-15 09:59:02 +01:00
|
|
|
# The "command dispatch" system is taken from colobus - http://trainedmonkey.com/colobus/
|
|
|
|
#
|
2009-04-03 08:34:12 +02:00
|
|
|
# For more information see http://smtpd.develooper.com/
|
2004-03-15 09:59:02 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
use lib 'lib';
|
|
|
|
use Qpsmtpd::TcpServer;
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
use IO::Socket;
|
2005-07-05 17:16:36 +02:00
|
|
|
use IO::Select;
|
2004-03-15 09:59:02 +01:00
|
|
|
use Socket;
|
2007-05-18 00:09:33 +02:00
|
|
|
use Getopt::Long qw(:config no_ignore_case);
|
2004-03-19 00:02:43 +01:00
|
|
|
use POSIX qw(:sys_wait_h :errno_h :signal_h);
|
2006-12-16 10:42:52 +01:00
|
|
|
use Net::DNS::Header;
|
2004-03-15 09:59:02 +01:00
|
|
|
use strict;
|
|
|
|
$| = 1;
|
|
|
|
|
2007-05-18 00:16:27 +02:00
|
|
|
my $has_ipv6 = Qpsmtpd::TcpServer::has_ipv6;
|
2006-08-28 01:17:33 +02:00
|
|
|
|
|
|
|
if ($has_ipv6) {
|
2006-11-05 10:47:18 +01:00
|
|
|
eval 'use Socket6';
|
2006-08-28 01:17:33 +02:00
|
|
|
}
|
|
|
|
|
2004-04-15 04:19:01 +02:00
|
|
|
# Configuration
|
2005-07-06 09:53:41 +02:00
|
|
|
my $MAXCONN = 15; # max simultaneous connections
|
2006-03-01 17:44:20 +01:00
|
|
|
my @PORT; # port number(s)
|
2005-07-06 09:53:41 +02:00
|
|
|
my @LOCALADDR; # ip address(es) to bind to
|
|
|
|
my $MAXCONNIP = 5; # max simultaneous connections from one IP
|
2005-07-05 17:16:36 +02:00
|
|
|
my $PID_FILE = '';
|
2005-07-29 08:42:00 +02:00
|
|
|
my $DETACH; # daemonize on startup
|
2007-05-18 00:09:33 +02:00
|
|
|
my $NORDNS;
|
|
|
|
|
|
|
|
my $USER = (getpwuid $>)[0]; # user to suid to
|
|
|
|
$USER = "smtpd" if $USER eq "root";
|
2004-04-15 04:19:01 +02:00
|
|
|
|
2004-06-28 05:05:03 +02:00
|
|
|
sub usage {
|
|
|
|
print <<"EOT";
|
|
|
|
usage: qpsmtpd-forkserver [ options ]
|
2005-07-06 09:50:00 +02:00
|
|
|
-l, --listen-address addr : listen on specific address(es); can be specified
|
2007-05-18 00:16:27 +02:00
|
|
|
multiple times for multiple bindings. IPv6
|
|
|
|
addresses must be inside square brackets [], and
|
|
|
|
don't need to be zero padded.
|
|
|
|
Default is [::] (if has_ipv6) or 0.0.0.0 (if not)
|
2006-03-01 17:44:20 +01:00
|
|
|
-p, --port P : listen on a specific port; default 2525; can be
|
|
|
|
specified multiple times for multiple bindings.
|
2004-06-28 05:05:03 +02:00
|
|
|
-c, --limit-connections N : limit concurrent connections to N; default 15
|
2009-05-14 22:49:58 +02:00
|
|
|
-u, --user U : run as a particular user (default '$USER')
|
2004-11-29 04:37:38 +01:00
|
|
|
-m, --max-from-ip M : limit connections from a single IP; default 5
|
2005-07-04 16:44:51 +02:00
|
|
|
--pid-file P : print main servers PID to file P
|
2005-07-29 08:42:00 +02:00
|
|
|
-d, --detach : detach from controlling terminal (daemonize)
|
2007-05-18 00:09:33 +02:00
|
|
|
-H, --no-rdns : don't perform reverse DNS lookups
|
2004-06-28 05:05:03 +02:00
|
|
|
EOT
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetOptions('h|help' => \&usage,
|
2005-07-06 09:50:00 +02:00
|
|
|
'l|listen-address=s' => \@LOCALADDR,
|
2004-06-28 05:05:03 +02:00
|
|
|
'c|limit-connections=i' => \$MAXCONN,
|
2004-11-29 04:37:38 +01:00
|
|
|
'm|max-from-ip=i' => \$MAXCONNIP,
|
2006-03-01 17:44:20 +01:00
|
|
|
'p|port=s' => \@PORT,
|
2005-07-04 16:44:51 +02:00
|
|
|
'u|user=s' => \$USER,
|
2005-07-05 17:16:36 +02:00
|
|
|
'pid-file=s' => \$PID_FILE,
|
2005-07-29 08:42:00 +02:00
|
|
|
'd|detach' => \$DETACH,
|
2007-05-18 00:09:33 +02:00
|
|
|
'H|no-rdns' => \$NORDNS,
|
2006-03-01 17:44:20 +01:00
|
|
|
) || &usage;
|
2004-06-28 05:05:03 +02:00
|
|
|
|
|
|
|
# detaint the commandline
|
2006-08-28 01:17:33 +02:00
|
|
|
if ($has_ipv6) {
|
|
|
|
@LOCALADDR = ( '[::]' ) if !@LOCALADDR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
@LOCALADDR = ( '0.0.0.0' ) if !@LOCALADDR;
|
|
|
|
}
|
2006-03-01 17:44:20 +01:00
|
|
|
@PORT = ( 2525 ) if !@PORT;
|
|
|
|
|
|
|
|
my @LISTENADDR;
|
2005-07-06 09:50:00 +02:00
|
|
|
for (0..$#LOCALADDR) {
|
2006-08-28 01:17:33 +02:00
|
|
|
if ($LOCALADDR[$_] =~ /^(\[.*\]|[\d\w\-.]+)(?::(\d+))?$/) {
|
2006-03-01 17:44:20 +01:00
|
|
|
if ( defined $2 ) {
|
|
|
|
push @LISTENADDR, { 'addr' => $1, 'port' => $2 };
|
|
|
|
} else {
|
|
|
|
my $addr = $1;
|
|
|
|
for (0..$#PORT) {
|
|
|
|
if ( $PORT[$_] =~ /^(\d+)$/ ) {
|
|
|
|
push @LISTENADDR, { 'addr' => $addr, 'port' => $1 };
|
|
|
|
} else {
|
|
|
|
&usage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-07-06 09:50:00 +02:00
|
|
|
} else {
|
|
|
|
&usage;
|
|
|
|
}
|
|
|
|
}
|
2006-03-01 17:44:20 +01:00
|
|
|
|
2004-06-28 05:05:03 +02:00
|
|
|
if ($USER =~ /^([\w\-]+)$/) { $USER = $1 } else { &usage }
|
|
|
|
if ($MAXCONN =~ /^(\d+)$/) { $MAXCONN = $1 } else { &usage }
|
|
|
|
|
2004-03-15 09:59:02 +01:00
|
|
|
delete $ENV{ENV};
|
|
|
|
$ENV{PATH} = '/bin:/usr/bin:/var/qmail/bin';
|
|
|
|
|
2004-04-15 04:19:01 +02:00
|
|
|
my %childstatus = ();
|
|
|
|
|
2004-03-15 09:59:02 +01:00
|
|
|
sub REAPER {
|
2004-04-15 04:19:01 +02:00
|
|
|
while ( defined(my $chld = waitpid(-1, WNOHANG)) ){
|
|
|
|
last unless $chld > 0;
|
2005-03-24 22:16:35 +01:00
|
|
|
::log(LOGINFO,"cleaning up after $chld");
|
2004-04-15 04:19:01 +02:00
|
|
|
delete $childstatus{$chld};
|
|
|
|
}
|
2004-03-15 09:59:02 +01:00
|
|
|
}
|
|
|
|
|
2004-06-16 22:27:51 +02:00
|
|
|
sub HUNTSMAN {
|
|
|
|
$SIG{CHLD} = 'DEFAULT';
|
|
|
|
kill 'INT' => keys %childstatus;
|
2005-07-29 09:22:36 +02:00
|
|
|
if ($PID_FILE && -e $PID_FILE) {
|
2005-07-29 09:24:04 +02:00
|
|
|
unlink $PID_FILE or ::log(LOGERROR, "unlink: $PID_FILE: $!");
|
2005-07-29 09:22:36 +02:00
|
|
|
}
|
2004-06-16 22:27:51 +02:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
$SIG{INT} = \&HUNTSMAN;
|
|
|
|
$SIG{TERM} = \&HUNTSMAN;
|
2004-03-15 09:59:02 +01:00
|
|
|
|
2005-07-06 09:50:00 +02:00
|
|
|
my $select = new IO::Select;
|
2006-08-28 01:17:33 +02:00
|
|
|
my $server;
|
2005-07-06 09:50:00 +02:00
|
|
|
|
|
|
|
# establish SERVER socket(s), bind and listen.
|
2006-03-01 17:44:20 +01:00
|
|
|
for my $listen_addr (@LISTENADDR) {
|
2006-08-28 01:17:33 +02:00
|
|
|
my @Socket_opts = (LocalPort => $listen_addr->{'port'},
|
2006-02-28 22:10:11 +01:00
|
|
|
LocalAddr => $listen_addr->{'addr'},
|
2005-07-06 09:50:00 +02:00
|
|
|
Proto => 'tcp',
|
|
|
|
Reuse => 1,
|
|
|
|
Blocking => 0,
|
2006-08-28 01:17:33 +02:00
|
|
|
Listen => SOMAXCONN);
|
|
|
|
if ($has_ipv6) {
|
|
|
|
$server = IO::Socket::INET6->new(@Socket_opts)
|
|
|
|
or die "Creating TCP socket $listen_addr->{'addr'}:$listen_addr->{'port'}: $!\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$server = IO::Socket::INET->new(@Socket_opts)
|
|
|
|
or die "Creating TCP socket $listen_addr->{'addr'}:$listen_addr->{'port'}: $!\n";
|
|
|
|
}
|
2005-07-06 09:50:00 +02:00
|
|
|
IO::Handle::blocking($server, 0);
|
|
|
|
$select->add($server);
|
|
|
|
}
|
2004-03-15 09:59:02 +01:00
|
|
|
|
2005-07-05 17:16:36 +02:00
|
|
|
if ($PID_FILE) {
|
|
|
|
if ($PID_FILE =~ m#^(/[\w\d/\-.]+)$#) { $PID_FILE = $1 } else { &usage }
|
|
|
|
if (-e $PID_FILE) {
|
|
|
|
open PID, "+<$PID_FILE"
|
|
|
|
or die "open pid_file: $!\n";
|
2005-07-30 11:32:36 +02:00
|
|
|
my $running_pid = <PID> || ''; chomp $running_pid;
|
2005-07-05 17:16:36 +02:00
|
|
|
if ($running_pid =~ /(\d+)/) {
|
|
|
|
$running_pid = $1;
|
|
|
|
if (kill 0, $running_pid) {
|
|
|
|
die "Found an already running qpsmtpd with pid $running_pid.\n";
|
|
|
|
}
|
2005-07-04 16:44:51 +02:00
|
|
|
}
|
2005-07-05 17:16:36 +02:00
|
|
|
seek PID, 0, 0
|
|
|
|
or die "Could not seek back to beginning of $PID_FILE: $!\n";
|
2005-07-29 08:21:02 +02:00
|
|
|
truncate PID, 0
|
|
|
|
or die "Could not truncate $PID_FILE at 0: $!";
|
2005-07-05 17:16:36 +02:00
|
|
|
} else {
|
|
|
|
open PID, ">$PID_FILE"
|
|
|
|
or die "open pid_file: $!\n";
|
2005-07-04 16:44:51 +02:00
|
|
|
}
|
|
|
|
}
|
2005-07-05 17:16:36 +02:00
|
|
|
|
|
|
|
# Load plugins here
|
|
|
|
my $qpsmtpd = Qpsmtpd::TcpServer->new();
|
2005-07-04 16:44:51 +02:00
|
|
|
|
|
|
|
# Drop privileges
|
2004-04-15 04:19:01 +02:00
|
|
|
my (undef, undef, $quid, $qgid) = getpwnam $USER or
|
|
|
|
die "unable to determine uid/gid for $USER\n";
|
2005-07-04 16:44:51 +02:00
|
|
|
my $groups = "$qgid $qgid";
|
|
|
|
while (my ($name,$passwd,$gid,$members) = getgrent()) {
|
|
|
|
my @m = split(/ /, $members);
|
|
|
|
if (grep {$_ eq $USER} @m) {
|
2006-03-01 17:44:20 +01:00
|
|
|
$groups .= " $gid";
|
2005-07-04 16:44:51 +02:00
|
|
|
}
|
|
|
|
}
|
2007-05-18 00:09:33 +02:00
|
|
|
endgrent;
|
2005-07-04 16:44:51 +02:00
|
|
|
$) = $groups;
|
2004-03-15 09:59:02 +01:00
|
|
|
POSIX::setgid($qgid) or
|
|
|
|
die "unable to change gid: $!\n";
|
|
|
|
POSIX::setuid($quid) or
|
|
|
|
die "unable to change uid: $!\n";
|
|
|
|
$> = $quid;
|
|
|
|
|
2005-12-11 03:19:43 +01:00
|
|
|
$qpsmtpd->load_plugins;
|
|
|
|
|
2006-03-01 17:44:20 +01:00
|
|
|
foreach my $listen_addr ( @LISTENADDR ) {
|
|
|
|
::log(LOGINFO,"Listening on $listen_addr->{'addr'}:$listen_addr->{'port'}");
|
2006-02-28 22:10:11 +01:00
|
|
|
}
|
2005-03-24 22:16:35 +01:00
|
|
|
::log(LOGINFO, 'Running as user '.
|
2006-03-01 17:44:20 +01:00
|
|
|
(getpwuid($>) || $>) .
|
|
|
|
', group '.
|
|
|
|
(getgrgid($)) || $)));
|
2004-03-15 09:59:02 +01:00
|
|
|
|
2005-07-29 08:42:00 +02:00
|
|
|
if ($DETACH) {
|
|
|
|
open STDIN, '/dev/null' or die "/dev/null: $!";
|
|
|
|
open STDOUT, '>/dev/null' or die "/dev/null: $!";
|
|
|
|
open STDERR, '>&STDOUT' or die "open(stderr): $!";
|
|
|
|
defined (my $pid = fork) or die "fork: $!";
|
|
|
|
exit 0 if $pid;
|
|
|
|
POSIX::setsid or die "setsid: $!";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($PID_FILE) {
|
|
|
|
print PID $$,"\n";
|
|
|
|
close PID;
|
|
|
|
}
|
|
|
|
|
2005-09-22 19:14:20 +02:00
|
|
|
# Populate class cached variables
|
|
|
|
$qpsmtpd->spool_dir;
|
|
|
|
$qpsmtpd->size_threshold;
|
|
|
|
|
2008-06-15 11:28:02 +02:00
|
|
|
$SIG{HUP} = sub {
|
|
|
|
$qpsmtpd = Qpsmtpd::TcpServer->new('restart' => 1);
|
|
|
|
$qpsmtpd->load_plugins;
|
|
|
|
$qpsmtpd->spool_dir;
|
|
|
|
$qpsmtpd->size_threshold;
|
|
|
|
};
|
|
|
|
|
2004-03-15 09:59:02 +01:00
|
|
|
while (1) {
|
2005-07-05 17:16:36 +02:00
|
|
|
REAPER();
|
2004-04-15 04:19:01 +02:00
|
|
|
my $running = scalar keys %childstatus;
|
2005-07-05 17:25:54 +02:00
|
|
|
if ($running >= $MAXCONN) {
|
2004-04-15 04:19:01 +02:00
|
|
|
::log(LOGINFO,"Too many connections: $running >= $MAXCONN. Waiting one second.");
|
2005-07-05 17:20:40 +02:00
|
|
|
sleep(1);
|
|
|
|
next;
|
2005-07-05 17:16:36 +02:00
|
|
|
}
|
2005-07-06 09:50:00 +02:00
|
|
|
my @ready = $select->can_read(1);
|
|
|
|
next if !@ready;
|
2005-07-06 14:13:53 +02:00
|
|
|
while (my $server = shift @ready) {
|
|
|
|
my ($client, $hisaddr) = $server->accept;
|
|
|
|
|
|
|
|
if (!$hisaddr) {
|
|
|
|
# possible something condition...
|
|
|
|
next;
|
2004-07-05 21:20:15 +02:00
|
|
|
}
|
2005-07-06 14:13:53 +02:00
|
|
|
IO::Handle::blocking($client, 1);
|
2007-05-18 00:16:27 +02:00
|
|
|
# get local/remote hostname, port and ip address
|
|
|
|
my ($port, $iaddr, $lport, $laddr, $nto_iaddr, $nto_laddr) = Qpsmtpd::TcpServer::lrpip($server, $client, $hisaddr);
|
2006-01-11 17:21:08 +01:00
|
|
|
|
|
|
|
my ($rc, @msg) = $qpsmtpd->run_hooks("pre-connection",
|
2006-08-28 01:17:33 +02:00
|
|
|
remote_ip => $nto_iaddr,
|
2006-01-11 17:21:08 +01:00
|
|
|
remote_port => $port,
|
2006-08-28 01:17:33 +02:00
|
|
|
local_ip => $nto_laddr,
|
2006-01-11 17:21:08 +01:00
|
|
|
local_port => $lport,
|
|
|
|
max_conn_ip => $MAXCONNIP,
|
|
|
|
child_addrs => [values %childstatus],
|
|
|
|
);
|
|
|
|
if ($rc == DENYSOFT || $rc == DENYSOFT_DISCONNECT) {
|
|
|
|
unless ($msg[0]) {
|
|
|
|
@msg = ("Sorry, try again later");
|
2005-07-06 14:13:53 +02:00
|
|
|
}
|
2006-01-11 17:21:08 +01:00
|
|
|
&respond_client($client, 451, @msg);
|
|
|
|
close $client;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY || $rc == DENY_DISCONNECT) {
|
|
|
|
unless ($msg[0]) {
|
|
|
|
@msg = ("Sorry, service not available for you");
|
2005-07-06 14:13:53 +02:00
|
|
|
}
|
2006-01-11 17:21:08 +01:00
|
|
|
&respond_client($client, 550, @msg);
|
|
|
|
close $client;
|
|
|
|
next;
|
2005-07-06 14:13:53 +02:00
|
|
|
}
|
2006-01-11 17:21:08 +01:00
|
|
|
|
2005-07-06 14:13:53 +02:00
|
|
|
my $pid = safe_fork();
|
|
|
|
if ($pid) {
|
|
|
|
# parent
|
2006-03-01 17:44:20 +01:00
|
|
|
$childstatus{$pid} = $iaddr; # add to table
|
|
|
|
# $childstatus{$pid} = 1; # add to table
|
2005-07-06 14:13:53 +02:00
|
|
|
$running++;
|
|
|
|
close($client);
|
2005-07-06 09:53:41 +02:00
|
|
|
next;
|
2004-03-19 00:02:43 +01:00
|
|
|
}
|
2005-07-06 14:13:53 +02:00
|
|
|
# otherwise child
|
|
|
|
|
|
|
|
# all children should have different seeds, to prevent conflicts
|
2006-12-16 10:42:52 +01:00
|
|
|
srand();
|
|
|
|
for (0 .. rand(65536)) {
|
|
|
|
Net::DNS::Header::nextid();
|
|
|
|
}
|
2005-07-06 09:53:41 +02:00
|
|
|
|
2007-05-18 00:09:33 +02:00
|
|
|
close $_ for $select->handles;
|
2005-07-06 09:53:41 +02:00
|
|
|
|
2005-07-06 14:13:53 +02:00
|
|
|
$SIG{$_} = 'DEFAULT' for keys %SIG;
|
|
|
|
$SIG{ALRM} = sub {
|
|
|
|
print $client "421 Connection Timed Out\n";
|
|
|
|
::log(LOGINFO, "Connection Timed Out");
|
|
|
|
exit; };
|
2005-07-06 09:53:41 +02:00
|
|
|
|
2007-05-18 00:16:27 +02:00
|
|
|
# set enviroment variables
|
|
|
|
($ENV{TCPLOCALIP}, $ENV{TCPREMOTEIP}, $ENV{TCPREMOTEHOST}) = Qpsmtpd::TcpServer::tcpenv($nto_laddr, $nto_iaddr);
|
|
|
|
|
2005-07-06 14:13:53 +02:00
|
|
|
# don't do this!
|
|
|
|
#$0 = "qpsmtpd-forkserver: $ENV{TCPREMOTEIP} / $ENV{TCPREMOTEHOST}";
|
|
|
|
|
|
|
|
::log(LOGINFO, "Accepted connection $running/$MAXCONN from $ENV{TCPREMOTEIP} / $ENV{TCPREMOTEHOST}");
|
|
|
|
|
|
|
|
# dup to STDIN/STDOUT
|
|
|
|
POSIX::dup2(fileno($client), 0);
|
|
|
|
POSIX::dup2(fileno($client), 1);
|
|
|
|
|
|
|
|
$qpsmtpd->start_connection
|
|
|
|
(
|
|
|
|
local_ip => $ENV{TCPLOCALIP},
|
|
|
|
local_port => $lport,
|
|
|
|
remote_ip => $ENV{TCPREMOTEIP},
|
|
|
|
remote_port => $port,
|
|
|
|
);
|
2008-09-26 19:40:04 +02:00
|
|
|
$qpsmtpd->run($client);
|
2005-07-06 14:13:53 +02:00
|
|
|
|
2006-01-11 17:21:08 +01:00
|
|
|
$qpsmtpd->run_hooks("post-connection");
|
2008-05-09 19:40:31 +02:00
|
|
|
$qpsmtpd->connection->reset;
|
2008-10-24 19:18:08 +02:00
|
|
|
close $client;
|
2005-07-06 14:13:53 +02:00
|
|
|
exit; # child leaves
|
|
|
|
}
|
2004-03-15 09:59:02 +01:00
|
|
|
}
|
|
|
|
|
2004-04-15 04:19:01 +02:00
|
|
|
sub log {
|
|
|
|
my ($level,$message) = @_;
|
2005-05-25 22:07:58 +02:00
|
|
|
$qpsmtpd->log($level,$message);
|
2004-04-15 04:19:01 +02:00
|
|
|
}
|
|
|
|
|
2006-01-11 17:21:08 +01:00
|
|
|
sub respond_client {
|
|
|
|
my ($client, $code, @message) = @_;
|
|
|
|
$client->autoflush(1);
|
|
|
|
while (my $msg = shift @message) {
|
|
|
|
my $line = $code . (@message?"-":" ").$msg;
|
|
|
|
::log(LOGDEBUG, $line);
|
|
|
|
print $client "$line\r\n"
|
|
|
|
or (::log(LOGERROR, "Could not print [$line]: $!"), return 0);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-07-05 17:16:36 +02:00
|
|
|
### routine to protect process during fork
|
|
|
|
sub safe_fork {
|
|
|
|
|
|
|
|
### block signal for fork
|
|
|
|
my $sigset = POSIX::SigSet->new(SIGINT);
|
|
|
|
POSIX::sigprocmask(SIG_BLOCK, $sigset)
|
|
|
|
or die "Can't block SIGINT for fork: [$!]\n";
|
|
|
|
|
|
|
|
### fork off a child
|
|
|
|
my $pid = fork;
|
|
|
|
unless( defined $pid ){
|
|
|
|
die "Couldn't fork: [$!]\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
### make SIGINT kill us as it did before
|
|
|
|
$SIG{INT} = 'DEFAULT';
|
|
|
|
|
|
|
|
### put back to normal
|
|
|
|
POSIX::sigprocmask(SIG_UNBLOCK, $sigset)
|
|
|
|
or die "Can't unblock SIGINT for fork: [$!]\n";
|
|
|
|
|
|
|
|
return $pid;
|
|
|
|
}
|
|
|
|
|
2004-03-15 09:59:02 +01:00
|
|
|
__END__
|
|
|
|
|
|
|
|
1;
|