summaryrefslogtreecommitdiff
path: root/source4/selftest/env/Samba3.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-02 17:47:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:34 -0500
commite94addfd498a1fcd0003c49d9b5b1552965f406b (patch)
tree95c7a21ff870d13120d234c9ec4ae814a1e83bb8 /source4/selftest/env/Samba3.pm
parentc0091046263d9568a379f8ed9afd4a08f86b6c84 (diff)
downloadsamba-e94addfd498a1fcd0003c49d9b5b1552965f406b.tar.gz
samba-e94addfd498a1fcd0003c49d9b5b1552965f406b.tar.bz2
samba-e94addfd498a1fcd0003c49d9b5b1552965f406b.zip
r24901: Somewhat easier and more reliable access to the pid files.
(This used to be commit 91a0a00e6df4527948a2259ef2f7275f81c42cf1)
Diffstat (limited to 'source4/selftest/env/Samba3.pm')
-rw-r--r--source4/selftest/env/Samba3.pm57
1 files changed, 34 insertions, 23 deletions
diff --git a/source4/selftest/env/Samba3.pm b/source4/selftest/env/Samba3.pm
index 22c6f59987..2489b53952 100644
--- a/source4/selftest/env/Samba3.pm
+++ b/source4/selftest/env/Samba3.pm
@@ -34,8 +34,13 @@ sub teardown_env($$)
{
my ($self, $envvars) = @_;
- $self->samba3_stop_sig_term($envvars->{PIDDIR});
- $self->samba3_stop_sig_kill($envvars->{PIDDIR});
+ my $smbdpid = read_pid($envvars, "smbd");
+ my $nmbdpid = read_pid($envvars, "nmbd");
+
+ $self->stop_sig_term($smbdpid);
+ $self->stop_sig_term($nmbdpid);
+ $self->stop_sig_kill($smbdpid);
+ $self->stop_sig_kill($nmbdpid);
return 0;
}
@@ -105,23 +110,33 @@ sub stop($)
my ($self) = @_;
}
-sub samba3_stop_sig_term($$) {
- my ($self, $piddir) = @_;
- my $ret = 0;
- kill("USR1", `cat $piddir/timelimit.nmbd.pid`) or \
- kill("ALRM", `cat $piddir/timelimit.nmbd.pid`) or $ret++;
+sub stop_sig_term($$) {
+ my ($self, $pid) = @_;
+ kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
+}
+
+sub stop_sig_kill($$) {
+ my ($self, $pid) = @_;
+ kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
+}
- kill("USR1", `cat $piddir/timelimit.smbd.pid`) or \
- kill("ALRM", `cat $piddir/timelimit.smbd.pid`) or $ret++;
+sub write_pid($$$)
+{
+ my ($env_vars, $app, $pid) = @_;
- return $ret;
+ open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
+ print PID $pid;
+ close(PID);
}
-sub samba3_stop_sig_kill($$) {
- my ($self, $piddir) = @_;
- kill("ALRM", `cat $piddir/timelimit.nmbd.pid`);
- kill("ALRM", `cat $piddir/timelimit.smbd.pid`);
- return 0;
+sub read_pid($$)
+{
+ my ($env_vars, $app) = @_;
+
+ open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
+ my $pid = <PID>;
+ close(PID);
+ return $pid;
}
sub check_or_start($$$$) {
@@ -135,11 +150,9 @@ sub check_or_start($$$$) {
open STDERR, '>&STDOUT';
$ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd");
- exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("nmbd"), "-F", "-S", "--no-process-group", "-d0" ,"-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start nmbd: $!");
+ exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("nmbd"), "-F", "-S", "-d0", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start nmbd: $!");
}
- open(PID, ">$env_vars->{PIDDIR}/timelimit.nmbd.pid");
- print PID $pid;
- close(PID);
+ write_pid($env_vars, "nmbd", $pid);
print "DONE\n";
unlink($env_vars->{SMBD_TEST_LOG});
@@ -150,11 +163,9 @@ sub check_or_start($$$$) {
open STDERR, '>&STDOUT';
$ENV{MAKE_TEST_BINARY} = $self->binpath("smbd");
- exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("smbd"), "-F", "-S", "--no-process-group", "-d0" ,"-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start smbd: $!");
+ exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("smbd"), "-F", "-S", "-d0" , "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start smbd: $!");
}
- open(PID, ">$env_vars->{PIDDIR}/timelimit.smbd.pid");
- print PID $pid;
- close(PID);
+ write_pid($env_vars, "smbd", $pid);
print "DONE\n";
return 0;