[24013] in Perl-Users-Digest
Perl-Users Digest, Issue: 6211 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 3 18:10:46 2004
Date: Wed, 3 Mar 2004 15:10:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 3 Mar 2004 Volume: 10 Number: 6211
Today's topics:
waitpid interrupted problem (Jason Godfrey)
Re: waitpid interrupted problem <usenet@morrow.me.uk>
Re: waitpid interrupted problem <jg2002@aptsolutions.com>
Re: webservices <kkeller-usenet@wombat.san-francisco.ca.us>
Re: webservices <ceo@nospan.on.net>
Re: webservices <hillmw@ram.lmtas.lmco.com>
Re: webservices <hillmw@ram.lmtas.lmco.com>
Re: webservices <glex_nospam@qwest.invalid>
Re: webservices <gnari@simnet.is>
Win32::GUI for College Course? (Mike)
Re: Win32::GUI for College Course? <ittyspam@yahoo.com>
Re: Win32::GUI for College Course? <ittyspam@yahoo.com>
Re: XML best practices (was: Python as replacement for (Giles Brown)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Mar 2004 10:49:08 -0800
From: jg2002@aptsolutions.com (Jason Godfrey)
Subject: waitpid interrupted problem
Message-Id: <697ac80b.0403031049.2d0deec1@posting.google.com>
Hello.
I'm using perl 5.8 on a Linux system. I have a script that fires off multiple
copies of a program, then goes through a loop doing a waitpid on each child
process. While the waitpid is going on I have an alarm going off every two
seconds to handle some other tasks.
I hit some unexpected behaivor that could be a bug.
Doing an strace it appears that perl calls wait4 with the pid I am waiting for.
After it is interrupted due to the signal wait4 is called again, but this time
it is called with -1 as the pid. My second child exits first, so the waitpid
for the first child returns with the exit of the second child.(The return value
for waitpid is the pid of the second child.) When I then do the waitpid for the
second child it fails because the second child no longer exsists.
An excerpt of the strace is below.
I can work around the problem by reworking the code to not wait for specific
pids. It does strike me as undesirable behaivor though. I was wondering if
anyone else has had experience with this or any comments?
Thanks
- Jason
clone2(child_stack=0, stack_size=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTI
D|SIGCHLD, child_tidptr=0x200000000002ede0) = 32201
write(1, "[oldisk.2] /tmp/diags/oldisk -fi"..., 67[oldisk.2] /tmp/diags/oldisk -
filename /dev/shm/oldiskTestFile3219
) = 67
clone2(child_stack=0, stack_size=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTI
D|SIGCHLD, child_tidptr=0x200000000002ede0) = 32202
rt_sigaction(SIGALRM, {0x20000000006ddce0, [], 0}, {SIG_DFL}, 8) = 0
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, {it_interval={0, 0
}, it_value={0, 0}}) = 0
wait4(32201, 0x60000fffffff9da0, 0, NULL) = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 20000000003dcdf1 (0) ---
rt_sigreturn() = ? (mask now [])
write(1, "|", 1|) = 1
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, {it_interval={0, 0
}, it_value={0, 0}}) = 0
wait4(-1, 0x60000fffffff9da0, 0, NULL) = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 20000000003dcdf1 (0) ---
rt_sigreturn() = ? (mask now [])
write(1, "\10", ) = 1
write(1, "/", 1/) = 1
(and so on till)
wait4(-1, [WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 32202
write(1, "Diag 1 (pid 32201 or 32202) exit"..., 42Diag 1 (pid 32201 or 32202) ex
ited with 0
) = 42
write(1, "Diag 1 (pid 32201) exited with 0"..., 33Diag 1 (pid 32201) exited with
0
) = 33
write(1, "\10", ) = 1
write(1, "\33[30m\33[42mPASS\33[0m(oldisk.1)\n", 29PASS(oldisk.1)
) = 29
lstat("/tmp/diagTestOutput.1", {st_mode=S_IFREG|0644, st_size=460, ...}) = 0
unlink("/tmp/diagTestOutput.1") = 0
wait4(32202, 0x60000fffffff9da0, 0, NULL) = -1 ECHILD (No child processes)
write(1, "Diag 2 (pid 32202 or -1) exited "..., 40Diag 2 (pid 32202 or -1) exite
d with -1
) = 40
------------------------------
Date: Wed, 3 Mar 2004 19:53:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: waitpid interrupted problem
Message-Id: <c25d3e$8l$1@wisteria.csv.warwick.ac.uk>
jg2002@aptsolutions.com (Jason Godfrey) wrote:
>
> Doing an strace it appears that perl calls wait4 with the pid I am waiting
> for. After it is interrupted due to the signal wait4 is called again, but
> this time it is called with -1 as the pid. My second child exits first, so
> the waitpid for the first child returns with the exit of the second
> child.(The return value for waitpid is the pid of the second child.) When I
> then do the waitpid for the second child it fails because the second child no
> longer exsists.
I *don't* see this behaviour with 5.8.2 i686-linux-thread-multi: command-line
and strace follow. Do you get the same results with this command?
Command:
strace perl -le'$SIG{ALRM} = "IGNORE";
$x = fork; defined $x or die "fork: $!";
$x or do { sleep 5; exit 1};
$y = fork; defined $y or die "fork: $!";
$y or do { sleep 6; exit 1};
alarm 2;
print waitpid $y, 0;
print waitpid $x, 0;'
Output:
22485
22484
Strace:
...
fork() = 22484
fork() = 22485
alarm(2) = 0
wait4(22485, 0xbffff3e8, 0, NULL) = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
wait4(22485, 0xbffff3e8, 0, NULL) = ? ERESTARTSYS (To be restarted)
--- SIGCHLD (Child exited) @ 0 (0) ---
wait4(22485, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 22485
--- SIGCHLD (Child exited) @ 0 (0) ---
brk(0) = 0x817c000
brk(0x817d000) = 0x817d000
wait4(22484, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 22484
...
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Wed, 03 Mar 2004 16:32:23 -0600
From: Jason Godfrey <jg2002@aptsolutions.com>
Subject: Re: waitpid interrupted problem
Message-Id: <40465CF7.5FCD9540@aptsolutions.com>
Ben Morrow wrote:
> I *don't* see this behaviour with 5.8.2 i686-linux-thread-multi: command-line
> and strace follow. Do you get the same results with this command?
>
> Command:
> strace perl -le'$SIG{ALRM} = "IGNORE";
> $x = fork; defined $x or die "fork: $!";
> $x or do { sleep 5; exit 1};
> $y = fork; defined $y or die "fork: $!";
> $y or do { sleep 6; exit 1};
> alarm 2;
> print waitpid $y, 0;
> print waitpid $x, 0;'
>
> Output:
> 22485
> 22484
No, with your script I don't see the behaivour either. However, with a slight
modification I can see it:
strace perl -le'sub sigAlarm{ $i++; }
$SIG{'ALRM'} = 'sigAlarm';
$x = fork; defined $x or die "fork: $!";
$x or do { sleep 5; exit 1};
$y = fork; defined $y or die "fork: $!";
$y or do { sleep 6; exit 1};
alarm 2;
print waitpid $y, 0;
print waitpid $x, 0;'
Output:
2008
-1
Strace:
rt_sigaction(SIGALRM, {0x20000000006ddce0, [], 0}, {SIG_DFL}, 8) = 0
clone2(child_stack=0, stack_size=0,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
child_tidptr=0x200000000002ede0) = 2008
clone2(child_stack=0, stack_size=0,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
child_tidptr=0x200000000002ede0) = 2009
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, {it_interval={0, 0},
it_value={0, 0}}) = 0
wait4(2009, 0x60000fffffff9510, 0, NULL) = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 20000000003dcdf1 (0) ---
rt_sigreturn() = ? (mask now [])
wait4(-1, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 2008
write(1, "2008\n", ) = 5
wait4(2008, 0x60000fffffff9510, 0, NULL) = -1 ECHILD (No child processes)
write(1, "-1\n", 3) = 3
Thanks
- Jason
>
------------------------------
Date: Wed, 3 Mar 2004 08:18:52 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: webservices
Message-Id: <ch052c.i3o.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-03-03, Michael Hill <hillmw@charter.net> wrote:
[TOFU fixed--please don't top-post unnecessarily]
> "Gregory Toomey" <nospam@bigpond.com> wrote in message
> news:4881562.lYQKc4rPMD@GMT-hosting-and-pickle-farming...
>> Michael Hill wrote:
>>
>> > Does anyone know of a good example of a perl webservice?
>>
>> LWP::Simple; print
[snip]
> Is that what you are thinking?
Who knows? He was as specific as you were in your original post. Perhaps
if you describe what you're looking for you'll get a more specific answer.
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFARgVohVcNCxZ5ID8RAvc+AJ9N07sHFFHGUqWY0eS3nfcuQ1or/wCfSRci
lf31aI+xs9J+XuyHZ5lUbXc=
=eRms
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 03 Mar 2004 18:20:37 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: webservices
Message-Id: <Vlp1c.55423$Dn7.19540@newssvr33.news.prodigy.com>
Michael Hill wrote:
> Does anyone know of a good example of a perl webservice?
>
As someone pointed out already, your question is a bit ambiguous. "Web
Services" is a "cutesy" term used by high level people (eg. managers,
CIOs, etc.) to describe something they can pretend to know about. There
are different ways of creating them from roll your own to some that pose
as standards and those are standardized to some degree.
What do you want? SOAP? XML-RPC? And there have to be dozens of
examples on the net already documented and explained in either of those
in Perl. Try to be more specific and you'll get a specific answer. The
technical types in here respond better to technical questions and not
"cutsey" terms like "Web Services".
Try Googling for terms like "Perl SOAP" or "Perl XML RPC" and see what
you come up with.
chris
-----
Chris Olive
chris -at- --spammer-speed-bump-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")
------------------------------
Date: Wed, 03 Mar 2004 14:45:32 -0600
From: Michael Hill <hillmw@ram.lmtas.lmco.com>
To: Chris <ceo@nospan.on.net>
Subject: Re: webservices
Message-Id: <404643EC.DF7A2D58@ram.lmtas.lmco.com>
> Try Googling for terms like "Perl SOAP" or "Perl XML RPC" and see what
> you come up with.
>
> chris
> -----
Thank you very much .... I can't ask any more specific questions yet
because I don't know enough ..... but in a bit I'll be smarter to ask
better questions.
Mike
------------------------------
Date: Wed, 03 Mar 2004 15:13:41 -0600
From: Michael Hill <hillmw@ram.lmtas.lmco.com>
To: Chris <ceo@nospan.on.net>
Subject: Re: webservices
Message-Id: <40464A85.9E709AB5@ram.lmtas.lmco.com>
Hopefully this is better. The problem with this is that the product of
$result from the script.pl is xml. So what I am trying to do here is
feed the results of lwp ( which is an xml file ) into xml::simple and
get a hash structure.
Is this possible?
Mike
#!/usr/bin/perl -w
#
# Create a user agent object
use LWP::UserAgent;
use XML::Simple;
#has for xml
%config = ();
$ua = new LWP::UserAgent();
#this produces an xml structure like:
#<file>
#<stuff>mystuff</stuff>
#</file>
$request = new HTTP::Request('GET','http://blah.com/script.pl');
$result = $ua->request($request);
$config = XMLin($result);
#set-up the html
print "Content-type:text/html\n\n";
print <<EndOfHTML0;
<html>
<head>
<title></title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
EndOfHTML0
;
foreach my $x ( keys %config )
{
foreach my $y ( $config{$x} )
{
print " $x, $y<br>";
}
}
print "</body>\n";
print "</html>\n";
------------------------------
Date: Wed, 03 Mar 2004 15:38:11 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: webservices
Message-Id: <bfs1c.532$9f.46621@news.uswest.net>
Michael Hill wrote:
> Hopefully this is better. The problem with this is that the product of
> $result from the script.pl is xml. So what I am trying to do here is
> feed the results of lwp ( which is an xml file ) into xml::simple and
> get a hash structure.
>
> Is this possible?
Of course.
> $result = $ua->request($request);
>
> $config = XMLin($result);
Do some error checking! $result isn't what you think it is. Print it
out to see. Check the perldocs for LWP::UserAgent for how to access the
"content".
------------------------------
Date: Wed, 3 Mar 2004 21:45:28 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: webservices
Message-Id: <c25jjs$498$1@news.simnet.is>
"Michael Hill" <hillmw@ram.lmtas.lmco.com> wrote in message
news:40464A85.9E709AB5@ram.lmtas.lmco.com...
> Hopefully this is better. The problem with this is that the product of
> $result from the script.pl is xml. So what I am trying to do here is
> feed the results of lwp ( which is an xml file ) into xml::simple and
> get a hash structure.
>
> Is this possible?
I imagine so.
> ...
> #!/usr/bin/perl -w
> #
i will not mention the missing use strict,
> ...
> #has for xml
> %config = ();
> ...
> $config = XMLin($result);
>...
> foreach my $x ( keys %config )
> {
> foreach my $y ( $config{$x} )
> {
> print " $x, $y<br>";
> }
> }
>
I have no idea what you imagine these nested loops
will print, but note that you 'declared' %config but
never filled it. on the other hand the return of XMLin()
was assigned to the ref $config. there seems to be some
confusion here.
what you want to do MAY be :
a) skip the %config=()
b) change the loops to something like:
for my $key (keys %$config) {
print " $key,$config->{$key}<br>";
}
c) clean up the code so that it compiles with
use strict and does not generate warnings.
(and I do not mean by removing the -w,
although a use warnings is preferred nowadays)
gnari
------------------------------
Date: 3 Mar 2004 11:00:56 -0800
From: csdude@hotmail.com (Mike)
Subject: Win32::GUI for College Course?
Message-Id: <46cdc619.0403031100.4a81cf6e@posting.google.com>
I'm teaching an Adv. Programming class at the local community college,
and the first part of the semester is in Perl. We had originally
decided to teach PHP for the last half, but now I'm debating on
whether this should be switched to teaching the Win32::GUI instead.
However, this is a new module for me, so I'm a little hesitant.
Before I decide, I'm hoping to get some feedback from people that are
already using it:
1. With a good Perl background, am I going to be able to teach myself
enough about this module inside of 2 weeks for 8 weeks of class?
2. Does this do what I think it does? In reading the manual, it seems
as if it will "compile" a Perl program into a type of executable
(.plx). Does the end user have to have Perl installed on their
computer?
3. At the school, our servers are running Unix, and this is what we
host our scripts on. However, we use WinXP as our machines, and we
Putty into the server to code. In this instance, will we run the .plx
from the Unix server, or from the Windows terminal?
4. Finally, what is the scope of this module? Is it used widely enough
to make it worth teaching, or should I stick with PHP?
FYI, the students have already had COBOL, Java, C++, .NET (blah), and
Perl.
TIA,
Mike
------------------------------
Date: Wed, 3 Mar 2004 14:31:03 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Win32::GUI for College Course?
Message-Id: <20040303142545.N27834@dishwasher.cs.rpi.edu>
On Wed, 3 Mar 2004, Mike wrote:
> I'm teaching an Adv. Programming class at the local community college,
> and the first part of the semester is in Perl. We had originally
> decided to teach PHP for the last half, but now I'm debating on
> whether this should be switched to teaching the Win32::GUI instead.
> However, this is a new module for me, so I'm a little hesitant.
>
> Before I decide, I'm hoping to get some feedback from people that are
> already using it:
>
> 1. With a good Perl background, am I going to be able to teach myself
> enough about this module inside of 2 weeks for 8 weeks of class?
That depends entirely on you. How well are you able to learn new
material? I don't think Win32::GUI is any more difficult than learning
any other new programming aspect.
> 2. Does this do what I think it does? In reading the manual, it seems
> as if it will "compile" a Perl program into a type of executable
> (.plx). Does the end user have to have Perl installed on their
> computer?
No, it does not 'compile' anything. A perl program is a script,
regardless of what modules it uses. The .plx is just the extention the
author of whatever examples you've read has chosen to use for his/her
scripts. Yes, the end user will still need to have Perl installed.
(Note that there are other solutions available. There is a shareware
perl2exe program, for example. But that's unrelated to your question.)
> 3. At the school, our servers are running Unix, and this is what we
> host our scripts on. However, we use WinXP as our machines, and we
> Putty into the server to code. In this instance, will we run the .plx
> from the Unix server, or from the Windows terminal?
From Windows. Win32::[anything] isn't going to run on any non-Windows
platform. You will want to have a windows distribution of Perl
(likely either ActiveState or CygWin) installed on the Windows machines.
> 4. Finally, what is the scope of this module? Is it used widely enough
> to make it worth teaching, or should I stick with PHP?
That question is non-sensical. Perl with Win32::GUI is used to create
applications to be run on a Windows machine. PHP is (generally) used to
create websites and web-based applications. What you teach depends on
what kinds of applications you're wanting your students to create.
Paul Lalli
------------------------------
Date: Wed, 3 Mar 2004 14:36:07 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Win32::GUI for College Course?
Message-Id: <20040303143404.U27834@dishwasher.cs.rpi.edu>
On Wed, 3 Mar 2004, Paul Lalli wrote:
> On Wed, 3 Mar 2004, Mike wrote:
>
>
> > 3. At the school, our servers are running Unix, and this is what we
> > host our scripts on. However, we use WinXP as our machines, and we
> > Putty into the server to code. In this instance, will we run the .plx
> > from the Unix server, or from the Windows terminal?
>
> From Windows. Win32::[anything] isn't going to run on any non-Windows
> platform. You will want to have a windows distribution of Perl
> (likely either ActiveState or CygWin) installed on the Windows machines.
>
> > 4. Finally, what is the scope of this module? Is it used widely enough
> > to make it worth teaching, or should I stick with PHP?
>
> That question is non-sensical. Perl with Win32::GUI is used to create
> applications to be run on a Windows machine. PHP is (generally) used to
> create websites and web-based applications. What you teach depends on
> what kinds of applications you're wanting your students to create.
>
> Paul Lalli
>
I probably should also have mentioned that if you want to teach Graphical
User Interfaces using Perl, and you want to not be confined to Windows (as
Question 3 implies), you might want to check out Perl/Tk instead of Perl
with Win32::GUI. http://www.perltk.org/
------------------------------
Date: 3 Mar 2004 13:15:43 -0800
From: giles_brown@hotmail.com (Giles Brown)
Subject: Re: XML best practices (was: Python as replacement for PHP?)
Message-Id: <57de9986.0403031315.1bacf2c7@posting.google.com>
Andy Dingley <dingbat@codesmiths.com> wrote in message news:<1hd240haqpbmnqdltavdt6t24ue0jvcl92@4ax.com>...
> On Sat, 28 Feb 2004 03:54:49 -0000, claird@lairds.com (Cameron Laird)
> wrote:
>
> >Let me get this straight: your preferred vehicle for XML
> >parsing is Perl regular expressions? That's ... well,
>
> Rather more restrained a comment than I'd be capable of expressing ?
http://www.usingenglish.com/glossary/litotes.html maybe?
------------------------------
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 V10 Issue 6211
***************************************