-# $OpenBSD: Syslogd.pm,v 1.17 2015/12/30 13:15:52 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.18 2016/06/22 19:29:29 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
my $user = $dev eq "console" ?
"/dev/console" : "syslogd-regress";
my @cmd = (@sudo, "./ttylog", $user, $file);
- open(my $ctl, '|-', @cmd)
+ $self->{"pid$dev"} = open(my $ctl, '|-', @cmd)
or die ref($self), " pipe to @cmd failed: $!";
# remember until object is destroyed, autoclose will send EOF
$self->{"ctl$dev"} = $ctl;
return $self;
}
+sub ttykill {
+ my $self = shift;
+ my $dev = shift;
+ my $sig = shift;
+ my $pid = $self->{"pid$dev"}
+ or die ref($self), " no tty log pid$dev";
+
+ if (kill($sig => $pid) != 1) {
+ my $sudo = $ENV{SUDO};
+ $sudo && $!{EPERM}
+ or die ref($self), " kill $pid failed: $!";
+ my @cmd = ($sudo, '/bin/kill', "-$sig", $pid);
+ system(@cmd)
+ and die ref($self), " sudo kill $pid failed: $?";
+ }
+ return $self;
+}
+
sub child {
my $self = shift;
my @sudo = $ENV{SUDO} ? $ENV{SUDO} : ();
-# The client writes long messages to Sys::Syslog native method.
+# The client writes long messages while ttylog to user has been stopped.
# The syslogd writes it into a file and through a pipe and to tty.
# The syslogd passes it via UDP to the loghost.
# The server receives the message on its UDP socket.
client => {
func => sub {
my $self = shift;
- write_lines($self, 5, 900);
+ ${$self->{syslogd}}->ttykill("user", 'STOP');
+ write_lines($self, 9, 900);
+ ${$self->{syslogd}}->loggrep(qr/ttymsg delayed write/, 3);
+ ${$self->{syslogd}}->ttykill("user", 'CONT');
write_log($self);
},
},
},
user => {
loggrep => {
- qr/ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.* [12]$/ => 2,
+ qr/ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.* [12]/ => 2,
get_testgrep() => 1,
},
},