4 # delay lines for N seconds.
6 # primarily meant to be used with INN to generate a delayed feed with innfeed.
8 # put it into your newsfeeds file like
12 # :Tc,Wnm*,S16384:/usr/local/news/bin/delayer 60 \
13 # /usr/local/news/bin/startinnfeed -c innfeed-delayed.conf
17 # done by christian mock <cm@tahina.priv.at> sometime in july 1998,
18 # and put into the public domain.
20 $delay = shift || die "usage: $0 delay prog-n-args\n";
25 open(OUT, "|" . join(" ", @ARGV)) || die "open |prog-n-args: $!\n";
32 vec($rin,fileno(STDIN),1) = 1;
34 while(!$eof || $#queue >= 0) {
37 select($rout=$rin, undef, undef, $timeout);
41 $now = time(); $exp = $now + $delay;
43 if(!$eof && vec($rout,fileno(STDIN),1)) {
45 if(!defined $line) { # exit NOW!
54 push(@queue, "$exp:$line");
62 ($first, $line) = split(/:/, $queue[0], 2);
63 while($#queue >= 0 && $first <= $now) {
66 ($first, $line) = split(/:/, $queue[0], 2);
68 $timeout = $first - $now;