[30239] in Perl-Users-Digest
Perl-Users Digest, Issue: 1482 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 25 17:06:44 2008
Date: Fri, 25 Apr 2008 14:06:34 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 25 Apr 2008 Volume: 11 Number: 1482
Today's topics:
Time::Local busted? <Mark.Seger@hp.com>
Re: Time::Local busted? <smallpond@juno.com>
Re: Time::Local busted? xhoster@gmail.com
Re: Time::Local busted? <ben@morrow.me.uk>
Re: Time::Local busted? <smallpond@juno.com>
Trying to get a simple SOAP server to work <Phillip.Ross.Taylor@gmail.com>
Re: Trying to get a simple SOAP server to work <glex_no-spam@qwest-spam-no.invalid>
Re: use of DBI; I am getting multiple error messages mi <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Apr 2008 09:00:45 -0400
From: Mark Seger <Mark.Seger@hp.com>
Subject: Time::Local busted?
Message-Id: <fuq0a3$fu3$1@usenet01.boi.hp.com>
I have a script that tails a file and on a SIGTERM I want it to exit.
Sounds simple enough. It traps the signal, executes an 'exit', and then
hangs! The real odd thing is one of the modules I'm 'using' is
Time::Local. If I comment it out the script exits on SIGTERM and if it
leave it in it doesn't. The only way I was able to figure this out was
methodically removing pieces of code until it worked correctly and as
you might guess, the last thing I thought of was removing some of the
'use' statements. Anyhow this leads to a few questions:
- does anyone have a clue what this is breaking things?
- how would you have tracked down this problem with the Time module
- how can I make this work correctly AND use Time?
Anyhow, here's a pretty small piece of code that fails! Just comment
out the 'use Time' and it works...
#!/usr/bin/perl -w
use strict;
use Time::Local;
print "PID: $$\n";
$SIG{"TERM"}=\&sigTerm; # default kill command
while(1) {
open TAIL, "tail -f /var/log/aggregate|" or die;
while (my $line=<TAIL>) {
my $x=1;
}
}
sub sigTerm {
print "SIGTERM\n";
exit(1);
}
here's what I see when I execute a 'kill' from another window:
[root@cag-dl380-01 tmp]# ./test9.pl
PID: 13796
SIGTERM
and it's hung... Now if I comment out Time:
[root@cag-dl380-01 tmp]# ./test9.pl
PID: 13799
SIGTERM
[root@cag-dl380-01 tmp]#
-mark
------------------------------
Date: Thu, 24 Apr 2008 07:20:57 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Time::Local busted?
Message-Id: <cc154464-f942-45c6-a4a0-c3305be2c2eb@a1g2000hsb.googlegroups.com>
On Apr 24, 9:00 am, Mark Seger <Mark.Se...@hp.com> wrote:
> I have a script that tails a file and on a SIGTERM I want it to exit.
> Sounds simple enough. It traps the signal, executes an 'exit', and then
> hangs! The real odd thing is one of the modules I'm 'using' is
> Time::Local. If I comment it out the script exits on SIGTERM and if it
> leave it in it doesn't. The only way I was able to figure this out was
> methodically removing pieces of code until it worked correctly and as
> you might guess, the last thing I thought of was removing some of the
> 'use' statements. Anyhow this leads to a few questions:
>
> - does anyone have a clue what this is breaking things?
> - how would you have tracked down this problem with the Time module
> - how can I make this work correctly AND use Time?
>
> Anyhow, here's a pretty small piece of code that fails! Just comment
> out the 'use Time' and it works...
>
> #!/usr/bin/perl -w
>
> use strict;
> use Time::Local;
>
> print "PID: $$\n";
> $SIG{"TERM"}=\&sigTerm; # default kill command
> while(1) {
> open TAIL, "tail -f /var/log/aggregate|" or die;
> while (my $line=<TAIL>) {
> my $x=1;
> }
>
> }
>
> sub sigTerm {
> print "SIGTERM\n";
> exit(1);
>
> }
>
> here's what I see when I execute a 'kill' from another window:
> [root@cag-dl380-01 tmp]# ./test9.pl
> PID: 13796
> SIGTERM
>
> and it's hung... Now if I comment out Time:
> [root@cag-dl380-01 tmp]# ./test9.pl
> PID: 13799
> SIGTERM
> [root@cag-dl380-01 tmp]#
>
> -mark
Why do you think this has anything to do with Time::Local?
What happens when you change that line to:
use Config;
You have an I/O running in a child process 'tail', and the
system is waiting for it to complete before ending the process.
--S
------------------------------
Date: 24 Apr 2008 14:46:47 GMT
From: xhoster@gmail.com
Subject: Re: Time::Local busted?
Message-Id: <20080424104648.484$n9@newsreader.com>
Mark Seger <Mark.Seger@hp.com> wrote:
> I have a script that tails a file and on a SIGTERM I want it to exit.
> Sounds simple enough. It traps the signal, executes an 'exit', and then
> hangs! The real odd thing is one of the modules I'm 'using' is
> Time::Local. If I comment it out the script exits on SIGTERM and if it
> leave it in it doesn't. The only way I was able to figure this out was
> methodically removing pieces of code until it worked correctly and as
> you might guess, the last thing I thought of was removing some of the
> 'use' statements. Anyhow this leads to a few questions:
>
> - does anyone have a clue what this is breaking things?
> - how would you have tracked down this problem with the Time module
The hang is because upon the clean up done at exit, the program is calling
waitpid to wait for the "tail -f ..." process.
Why Time::Local causes it to decide to clean up this process while
commenting out the Time::Local causes it to not clean it up is still a
mystery to me. The two behaviors are inconsistent, but it isn't clear to me
which one, if any, is the "more correct" behavior. The one without the
Time::Local silently leaves tail -f processes hanging around the system's
process table, which certainly isn't desirable.
> - how can I make this work correctly AND use Time?
Kill the tail, as shown below:
>
> Anyhow, here's a pretty small piece of code that fails! Just comment
> out the 'use Time' and it works...
>
> #!/usr/bin/perl -w
>
> use strict;
> use Time::Local;
>
> print "PID: $$\n";
my $kid_pid; #needs to be in scope of both open and sig_handler
> $SIG{"TERM"}=\&sigTerm; # default kill command
> while(1) {
> open TAIL, "tail -f /var/log/aggregate|" or die;
$kid_pid=open TAIL, "tail -f /var/log/aggregate|" or die;
> while (my $line=<TAIL>) {
> my $x=1;
> }
> }
>
> sub sigTerm {
> print "SIGTERM\n";
kill 15, $kid_pid;
> exit(1);
> }
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Thu, 24 Apr 2008 15:52:54 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Time::Local busted?
Message-Id: <6fj6e5-0m5.ln1@osiris.mauzo.dyndns.org>
Quoth Mark Seger <Mark.Seger@hp.com>:
> I have a script that tails a file and on a SIGTERM I want it to exit.
> Sounds simple enough. It traps the signal, executes an 'exit', and then
> hangs! The real odd thing is one of the modules I'm 'using' is
> Time::Local. If I comment it out the script exits on SIGTERM and if it
> leave it in it doesn't. The only way I was able to figure this out was
> methodically removing pieces of code until it worked correctly and as
> you might guess, the last thing I thought of was removing some of the
> 'use' statements. Anyhow this leads to a few questions:
>
> - does anyone have a clue what this is breaking things?
This is... odd. Time::Local isn't actually necessary; all that is needed
is Config, which is pulled in by Time::Local.
The program is hanging in exit because it is trying to wait(2) for tail,
which of course hasn't exitted yet. Perl closes its end of the pipe, and
expects tail to exit (possibly with SIGPIPE) as a result of that; but
because tail is not writing at the moment, it never realises the pipe
has closed. Presumably when tail had read another bufferfull of data
from /var/log/aggregate and actually got to the point of calling
write(2) on the pipe, it would have exitted; at which point perl's exit
would also complete properly.
What I don't understand is why this doesn't happen if Config isn't
loaded. Maybe something in Config defeats perl's usual 'Oh, I'm
exitting, so I'll just drop everything on the floor and let the OS clean
up' approach (which is usually a good idea on OSen that do clean up
properly, as the OS can do it much faster than perl can).
> - how would you have tracked down this problem with the Time module
Exactly as you did :). When a program's behaviour makes no sense, keep
cutting things out until you get the smallest possible case with the
same behaviour. At that point, you'll either be able to see what's going
on, or you'll have a perfect test case for a bug report :).
I would generally start by removing as many modules as possible, though.
There's a lot of code in there, and you don't know what it's doing. It's
easier to see what's going on if it's not there.
> - how can I make this work correctly AND use Time?
One way that works is to remember the pid of the tail process (open
returns it) and pass the SIGTERM on. Then tail exits in a timely
fashion, so perl can finish its exit.
Another way that works is to use POSIX::_exit instead of exit, as this
doesn't try to close filehandles and flush buffers but just exits
directly. The problem here is that if there is unwritten data in output
buffers somewhere you will lose it.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk The Levellers, 'Believers'
------------------------------
Date: Thu, 24 Apr 2008 08:06:31 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Time::Local busted?
Message-Id: <9f64670f-9596-4d8e-ac0b-1c4508e344f4@i76g2000hsf.googlegroups.com>
On Apr 24, 10:46 am, xhos...@gmail.com wrote:
> Mark Seger <Mark.Se...@hp.com> wrote:
> > I have a script that tails a file and on a SIGTERM I want it to exit.
> > Sounds simple enough. It traps the signal, executes an 'exit', and then
> > hangs! The real odd thing is one of the modules I'm 'using' is
> > Time::Local. If I comment it out the script exits on SIGTERM and if it
> > leave it in it doesn't. The only way I was able to figure this out was
> > methodically removing pieces of code until it worked correctly and as
> > you might guess, the last thing I thought of was removing some of the
> > 'use' statements. Anyhow this leads to a few questions:
>
> > - does anyone have a clue what this is breaking things?
> > - how would you have tracked down this problem with the Time module
>
> The hang is because upon the clean up done at exit, the program is calling
> waitpid to wait for the "tail -f ..." process.
>
> Why Time::Local causes it to decide to clean up this process while
> commenting out the Time::Local causes it to not clean it up is still a
> mystery to me. The two behaviors are inconsistent, but it isn't clear to me
> which one, if any, is the "more correct" behavior. The one without the
> Time::Local silently leaves tail -f processes hanging around the system's
> process table, which certainly isn't desirable.
>
> > - how can I make this work correctly AND use Time?
>
> Kill the tail, as shown below:
>
>
>
> > Anyhow, here's a pretty small piece of code that fails! Just comment
> > out the 'use Time' and it works...
>
> > #!/usr/bin/perl -w
>
> > use strict;
> > use Time::Local;
>
> > print "PID: $$\n";
>
> my $kid_pid; #needs to be in scope of both open and sig_handler
>
> > $SIG{"TERM"}=\&sigTerm; # default kill command
> > while(1) {
> > open TAIL, "tail -f /var/log/aggregate|" or die;
>
> $kid_pid=open TAIL, "tail -f /var/log/aggregate|" or die;
>
> > while (my $line=<TAIL>) {
> > my $x=1;
> > }
> > }
>
> > sub sigTerm {
> > print "SIGTERM\n";
>
> kill 15, $kid_pid;
>
> > exit(1);
> > }
>
> Xho
>
It might be better not to start a child process in
the first place. How to tail a file in perl is a FAQ.
perldoc -f tail
------------------------------
Date: Thu, 24 Apr 2008 11:20:17 -0700 (PDT)
From: Philluminati <Phillip.Ross.Taylor@gmail.com>
Subject: Trying to get a simple SOAP server to work
Message-Id: <4701ca0b-d4c3-4234-bfd1-02da3c6a40ec@w7g2000hsa.googlegroups.com>
I am trying to follow this guide to make a perl based SOAP server:
http://articles.techrepublic.com.com/5100-22-1046624.html
But the client times out waiting for a response. If I visit the perl
cgi script in the browser I get a "500 internal error" and when I look
in the apache error log I can see these messages, but I don't know
what they mean. Can someone help please?
[Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Subroutine new
redefined at /usr/lib/perl5/site_perl/5.8.5/SOAP/Parser.pm line 42.
[Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Subroutine DESTROY
redefined at /usr/lib/perl5/site_perl/5.8.5/SOAP/Parser.pm line 63.
[Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Subroutine new
redefined at /usr/lib/perl5/site_perl/5.8.5/SOAP/Transport/HTTP/
Server.pm line 13.
[Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Can't locate object
method "new" via package "HTTP::Response" (perhaps you forgot to load
"HTTP::Response"?) at /usr/lib/perl5/site_perl/5.8.5/SOAP/Transport/
HTTP.pm line 473.
[Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Premature end of
script headers: funcs.cgi
All the code I have used is under the hyper link mentioned at the top
of the page.
Phillip Taylor
------------------------------
Date: Thu, 24 Apr 2008 14:46:09 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Trying to get a simple SOAP server to work
Message-Id: <4810e381$0$33229$815e3792@news.qwest.net>
Philluminati wrote:
> I am trying to follow this guide to make a perl based SOAP server:
>
> http://articles.techrepublic.com.com/5100-22-1046624.html
>
> But the client times out waiting for a response. If I visit the perl
> cgi script in the browser I get a "500 internal error" and when I look
> in the apache error log I can see these messages, but I don't know
> what they mean. Can someone help please?
>
> [Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Subroutine new
> redefined at /usr/lib/perl5/site_perl/5.8.5/SOAP/Parser.pm line 42.
> [Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Subroutine DESTROY
> redefined at /usr/lib/perl5/site_perl/5.8.5/SOAP/Parser.pm line 63.
> [Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Subroutine new
> redefined at /usr/lib/perl5/site_perl/5.8.5/SOAP/Transport/HTTP/
> Server.pm line 13.
> [Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Can't locate object
> method "new" via package "HTTP::Response" (perhaps you forgot to load
> "HTTP::Response"?) at /usr/lib/perl5/site_perl/5.8.5/SOAP/Transport/
> HTTP.pm line 473.
Do you have LWP installed? Usually installed as part of libwww.
> [Thu Apr 24 19:38:26 2008] [error] [client MY_IP] Premature end of
> script headers: funcs.cgi
>
> All the code I have used is under the hyper link mentioned at the top
> of the page.
There are a few pieces of code there. Post your client and your Echo.pm.
First, though, ensure your code compiles:
perl -c whatever.cgi
perl -c client.pl
Also, ensure you have installed all of the needed modules and
the installation's 'make test' is successful.
------------------------------
Date: Fri, 25 Apr 2008 01:25:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: use of DBI; I am getting multiple error messages mixed in with ?the correct output.
Message-Id: <Xns9A8AD9F8C6025asu1cornelledu@127.0.0.1>
Ted <r.ted.byers@rogers.com> wrote in
news:f4fc5e2a-56e8-415f-b8bd-55d669300711@a70g2000hsh.googlegroups.com:
> On Apr 24, 6:31 pm, Martijn Lievaart <m...@rtij.nl.invlalid> wrote:
>> On Thu, 24 Apr 2008 14:10:08 +0000, Ben Bullock wrote:
>> > Ted <r.ted.by...@rogers.com> wrote:
>>
>> >>> Try running the following script to clarify what this means:
>>
>> >>> #!/usr/bin/perl
>> >>> use warnings;
>> >>> use strict;
>> >>> my $a;
>> >>> my $b = "";
>> >>> print "a is defined\n" if defined($a); print "b is defined\n" if
>> >>> defined($b);
>>
>> >>> Here $b is a "real null string" and $a is undefined.
>>
>> > Excuse me, this should say '$b is a "defined null string"' not
>> > "real".
>>
>> No, $b is an empty string. Certainly not a null string. There is no
>> such thing as a null string in perl. C++ has a null string concept
>> IIRC, but Java and C don't, they allow the variable to be set to
>> NULL, which in perl is setting it to undef.
>>
> FTR, C++ does not have a null string, at least not in the definition
> of the language or in the standard C++ library.
But NUL marks the end of the stirng. Either way, it looks like it is
time for the rest of us to ignore the rest of this thread.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1482
***************************************