diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-01-01 19:58:49 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-01-01 19:58:49 +0000 |
commit | ccff2e07abb6827f717a96e6bbb599a17239c0b6 (patch) | |
tree | be457c807bc4a34ea8df2d132c213230fa145334 /regress/usr.sbin/syslogd/funcs.pl | |
parent | 51e553bd0578523b79e10a6f95bede1af44cff93 (diff) |
Test that syslogd sending over TCP does not leak a file descriptor
when it receives a SIGHUP.
Diffstat (limited to 'regress/usr.sbin/syslogd/funcs.pl')
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index d71d73bbcc9..382ab1f8f70 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,6 +1,6 @@ -# $OpenBSD: funcs.pl,v 1.8 2014/12/28 14:08:01 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.9 2015/01/01 19:58:48 bluhm Exp $ -# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> +# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -115,10 +115,14 @@ sub read_between2logs { my $self = shift; my $func = shift; - read_message($self, $firstlog, @_); + unless ($self->{redo}) { + read_message($self, $firstlog, @_); + } $func->($self, @_); - read_message($self, $testlog, @_); - read_message($self, $downlog, @_); + unless ($self->{redo}) { + read_message($self, $testlog, @_); + read_message($self, $downlog, @_); + } } sub read_message { @@ -128,8 +132,9 @@ sub read_message { local $_; for (;;) { # reading udp packets works only with sysread() - defined(sysread(STDIN, $_, 8194)) + defined(my $n = sysread(STDIN, $_, 8194)) or die ref($self), " read log line failed: $!"; + last if $n == 0; chomp; print STDERR ">>> $_\n"; last if /$regex/; |