[29738] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 982 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 27 09:09:47 2007

Date: Sat, 27 Oct 2007 06:09:07 -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           Sat, 27 Oct 2007     Volume: 11 Number: 982

Today's topics:
    Re: daemon in perl <stoupa@practisoft.cz>
    Re: FAQ 5.11 How can I write() into a string? <hjp-usenet2@hjp.at>
    Re: FAQ 5.11 How can I write() into a string? <ben@morrow.me.uk>
    Re: FAQ 5.11 How can I write() into a string? <bik.mido@tiscalinet.it>
    Re: How to interactively sending the username/password  <praveenkandala@gmail.com>
    Re: IPC::Open3 and the error filehandle <ben@morrow.me.uk>
        new CPAN modules on Sat Oct 27 2007 (Randal Schwartz)
    Re: perl standard <hjp-usenet2@hjp.at>
    Re: perl standard <hjp-usenet2@hjp.at>
    Re: perl time function <hjp-usenet2@hjp.at>
    Re: perl time function <ben@morrow.me.uk>
    Re: PID of exec  hendedav@gmail.com
    Re: PID of exec  hendedav@gmail.com
    Re: PID of exec <ben@morrow.me.uk>
    Re: TeX pestilence <bik.mido@tiscalinet.it>
    Re: TeX pestilence <bik.mido@tiscalinet.it>
    Re: UTF8 strings and filesystem access <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 26 Oct 2007 18:16:08 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: daemon in perl
Message-Id: <fft41n$2u66$1@ns.felk.cvut.cz>

kaustabh.banerjee@gmail.com wrote:
> I have a perl daemon which queries the DB in every 10 secs and checks
> some data. The daemon runs fine for most of the time, but dies
> sometimes with some DB exceptions. I have put eval block to survive
> this.
>
> But still it breaks sometimes.
>
> How to survive any exception at all. I just want to run no matter
> what..

Very simple. Instead of
    $sth->execute() or die "error";
use some like this
    $sth->execute() or errorhandler("error on line XY");
-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)





------------------------------

Date: Sat, 27 Oct 2007 12:54:59 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 5.11 How can I write() into a string?
Message-Id: <slrnfi6683.77r.hjp-usenet2@zeno.hjp.at>

On 2007-10-11 07:03, PerlFAQ Server <brian@stonehenge.com> wrote:
> 5.11: How can I write() into a string?
>
>
>     See "Accessing Formatting Internals" in perlform for an swrite()
>     function.
>

I think a more useful companion question would be 

    How can I open a file handle to a string?

    Use open(my $fh, '>', \$string); or open(my $fh, '<', \$string);

If this is in the FAQ I haven't found it. 

	hp


-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


------------------------------

Date: Sat, 27 Oct 2007 12:52:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 5.11 How can I write() into a string?
Message-Id: <uclbv4-051.ln1@osiris.mauzo.dyndns.org>


Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> On 2007-10-11 07:03, PerlFAQ Server <brian@stonehenge.com> wrote:
> > 5.11: How can I write() into a string?
> >
> >     See "Accessing Formatting Internals" in perlform for an swrite()
> >     function.
> 
> I think a more useful companion question would be 
> 
>     How can I open a file handle to a string?
> 
>     Use open(my $fh, '>', \$string); or open(my $fh, '<', \$string);

With reference to IO::String for pre-5.8 perls?

Ben



------------------------------

Date: Sat, 27 Oct 2007 13:53:44 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 5.11 How can I write() into a string?
Message-Id: <0m96i3le50b9duajp994mta7ljste0sfb9@4ax.com>

On Sat, 27 Oct 2007 12:54:59 +0200, "Peter J. Holzer"
<hjp-usenet2@hjp.at> wrote:

>I think a more useful companion question would be 
>
>    How can I open a file handle to a string?
>
>    Use open(my $fh, '>', \$string); or open(my $fh, '<', \$string);

I second that.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 26 Oct 2007 19:13:30 -0700
From: praveen kandala <praveenkandala@gmail.com>
Subject: Re: How to interactively sending the username/password to login using ssh
Message-Id: <1193424698.948967.288320@t8g2000prg.googlegroups.com>

On Oct 26, 9:08 am, cyrusgre...@gmail.com wrote:
> On Oct 25, 5:05 pm, all mail refused <elvis-85...@notatla.org.uk>
> wrote:
>
> > On 2007-10-25, cyrusgre...@gmail.com <cyrusgre...@gmail.com> wrote:
>
> > > I'm trying to interactively sending the username/password to login and
>
> > passwordless logins are in the SSH docs and FAQ
> >  http://www.snailbook.com/faq/
>
> > "expect" deals with terminal input if you really need
> > to provide a password that way.  Various CPAN modules
> > involve it.
> >  http://search.cpan.org/search?query=expect&mode=module
>
> > --
> > Elvis Notargiacomo  master AT barefaced DOT cheekhttp://www.notatla.org.uk/goen/
>
> Thanks to you all I got it now.

Why not use Net::SSH::Perl module?

Praveen Kandala



------------------------------

Date: Fri, 26 Oct 2007 23:57:20 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: IPC::Open3 and the error filehandle
Message-Id: <gv7av4-136.ln1@osiris.mauzo.dyndns.org>


Quoth xhoster@gmail.com:
> Peter Makholm <peter@makholm.net> wrote:
> >
> > but calling gensym by hand seems oldschool. But is there a better way?
> 
> There is, but the better way would break backwards compatibility, which is
> probably why it hasn't been implemented.
> 
> The better way, IMHO, would be to make your own wrapper around open3
> that only sends STDERR to STDOUT if ERRFH is false but defined.  If ERRFH
> is undefined, then it would be converted into a file handle with gensym,
> just like the other two are.  Maybe this behavior could be put into
> IPC::Open3, but only turned on with a import flag.  That way backwards
> compatibility would be preserved.

Better would be to replace ERRFH iff it is undef-but-an-lvalue.
Something like

    sub open3  {
        unless (defined $_[2]) {
            local $@;
            require Symbol;
            eval { $_[2] = Symbol::gensym };
        }
        
        goto &IPC::Open3::open3;
    }

This will keep the behaviour of an explicit

    open3 $IN, $OUT, undef, ...;

which is more intuitive than having to use a false-but-defined value,
and matches the behaviour of open.

Ben



------------------------------

Date: Sat, 27 Oct 2007 04:42:14 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Oct 27 2007
Message-Id: <JqJzqE.EGy@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Apache-SWIT-0.3
http://search.cpan.org/~bosu/Apache-SWIT-0.3/
mod_perl based application server with integrated testing. 
----
App-Smbxfer-0.01
http://search.cpan.org/~kerisman/App-Smbxfer-0.01/
A "modulino" (module/program hybrid) for file transfer between Samba shares and the local filesystem. 
----
Authen-CAS-Client-0.01
http://search.cpan.org/~pravus/Authen-CAS-Client-0.01/
Provides an easy-to-use interface for authentication using JA-SIG's Central Authentication Service 
----
Bundle-CPAN-1.857
http://search.cpan.org/~andk/Bundle-CPAN-1.857/
Bundle to optimize the behaviour of CPAN.pm 
----
Business-TW-TSIB-VirtualAccount-0.02
http://search.cpan.org/~cornelius/Business-TW-TSIB-VirtualAccount-0.02/
Module for Taishin Bank Virtual Account Management 
----
Business-TW-TSIB-VirtualAccount-0.03
http://search.cpan.org/~cornelius/Business-TW-TSIB-VirtualAccount-0.03/
Module for Taishin Bank Virtual Account Management 
----
CGI-Application-Plugin-Config-IniFiles-0.03
http://search.cpan.org/~arto/CGI-Application-Plugin-Config-IniFiles-0.03/
Add Config::IniFiles support to CGI::Application. 
----
CPAN-Reporter-1.04
http://search.cpan.org/~dagolden/CPAN-Reporter-1.04/
Adds CPAN Testers reporting to CPAN.pm 
----
Catalyst-Model-WebService-Lucene-0.03
http://search.cpan.org/~bricas/Catalyst-Model-WebService-Lucene-0.03/
Use WebService::Lucene in your Catalyst application 
----
Catalyst-Plugin-Authentication-Credential-OpenID-0.03
http://search.cpan.org/~miyagawa/Catalyst-Plugin-Authentication-Credential-OpenID-0.03/
OpenID credential for Catalyst::Auth framework 
----
Config-Model-Itself-0.101
http://search.cpan.org/~ddumont/Config-Model-Itself-0.101/
Model for Config::Model 
----
Config-Model-Xorg-0.506
http://search.cpan.org/~ddumont/Config-Model-Xorg-0.506/
Xorg configuration model for Config::Model 
----
Data-Integer-0.003
http://search.cpan.org/~zefram/Data-Integer-0.003/
details of the native integer data type 
----
Data-Serializer-0.42
http://search.cpan.org/~neely/Data-Serializer-0.42/
Modules that serialize data structures 
----
DateTime-Span-Birthdate-0.03
http://search.cpan.org/~miyagawa/DateTime-Span-Birthdate-0.03/
Date span of birthdays for an age 
----
Exception-Class-DBI-0.96
http://search.cpan.org/~dwheeler/Exception-Class-DBI-0.96/
DBI Exception objects 
----
Geo-Ov2-0.90_07
http://search.cpan.org/~hpa/Geo-Ov2-0.90_07/
Library for reading and writing TomTom Navigator .ov2 POI files. 
----
Geo-Ov2-0.91
http://search.cpan.org/~hpa/Geo-Ov2-0.91/
Library for reading and writing TomTom Navigator .ov2 POI files. 
----
HTML-Tested-0.3
http://search.cpan.org/~bosu/HTML-Tested-0.3/
Provides HTML widgets with the built-in means of testing. 
----
IO-Socket-SSL-1.12
http://search.cpan.org/~sullr/IO-Socket-SSL-1.12/
Nearly transparent SSL encapsulation for IO::Socket::INET. 
----
Jifty-DBI-0.45
http://search.cpan.org/~jesse/Jifty-DBI-0.45/
An object-relational persistence framework 
----
Lingua-EN-Conjugate-0.304
http://search.cpan.org/~rwg/Lingua-EN-Conjugate-0.304/
Conjugation of English verbs 
----
Mail-IMAPClient-2.99_02
http://search.cpan.org/~markov/Mail-IMAPClient-2.99_02/
An IMAP Client API 
----
Net-SCP-0.08
http://search.cpan.org/~ivan/Net-SCP-0.08/
Perl extension for secure copy protocol 
----
POE-Component-CPAN-YACSmoke-1.05
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-1.05/
Bringing the power of POE to CPAN smoke testing. 
----
Pod-Multi-0.07
http://search.cpan.org/~jkeenan/Pod-Multi-0.07/
pod2man, pod2text, pod2html simultaneously 
----
STAFService-0.06
http://search.cpan.org/~semuelf/STAFService-0.06/
Perl extension for writing STAF Services easily. 
----
Template-Alloy-1.008
http://search.cpan.org/~rhandom/Template-Alloy-1.008/
TT2/3, HT, HTE, Tmpl, and Velocity Engine 
----
Template-Plugin-Shuffle-0.02
http://search.cpan.org/~miyagawa/Template-Plugin-Shuffle-0.02/
TT Vmethods for shuffling lists 
----
Test-TempDatabase-0.12
http://search.cpan.org/~bosu/Test-TempDatabase-0.12/
temporary database creation and destruction. 
----
Tk-Pod-0.9936
http://search.cpan.org/~srezic/Tk-Pod-0.9936/
Pod browser toplevel widget 
----
WAP-SAXDriver-wbxml-2.05
http://search.cpan.org/~perrad/WAP-SAXDriver-wbxml-2.05/
SAX parser for WBXML file 
----
WAP-wbxml-1.11
http://search.cpan.org/~perrad/WAP-wbxml-1.11/
Binarization of XML file 
----
ack-1.69_01
http://search.cpan.org/~petdance/ack-1.69_01/
grep-like text finder 
----
pod2pdf-0.42
http://search.cpan.org/~jonallen/pod2pdf-0.42/
converts Pod to PDF format 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sat, 27 Oct 2007 12:07:19 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: perl standard
Message-Id: <slrnfi63en.77r.hjp-usenet2@zeno.hjp.at>

On 2007-10-19 22:28, Ben Bullock <benkasminbullock@gmail.com> wrote:
> On Fri, 19 Oct 2007 11:04:49 +0200, Dr.Ruud wrote:
>
>> ... The documentation is an important part of the implementation. So is
>> CPAN, for example all the testcode of the serious modules.
>
> What to do if Perl fails the tests though, or if the documentation and the
> program disagree?

"If the code and comments disagree, both are probably wrong" 

substitute comments for "tests and documentation" and you have your
answer: If there is a disagreement, it's a bug, and all sides have to be
examined carefully to determine whether the code or the test or the
documentation has to be changed. 

Standards do have bugs, too. They are just harder to fix. 

	hp

-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


------------------------------

Date: Sat, 27 Oct 2007 12:40:32 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: perl standard
Message-Id: <slrnfi65d4.77r.hjp-usenet2@zeno.hjp.at>

On 2007-10-21 05:06, David Formosa (aka ? the Platypus) <dformosa@usyd.edu.au> wrote:
> On 19 Oct 2007 10:30:11 GMT, Abigail <abigail@abigail.be> wrote:
>
>> Well, there's more to be said about the merits of a standard than
>> just dismissing it with "there's just one implementation".
>>
>> Read the O'Reilly interview [1] with Larry Rosler (a former clpm poster)
>> for instance. I don't necessarely agree with his conclusion, but he
>> makes some interesting arguments.

The argument about the "marketing value" of a standard has some merit.
But a standard is neither necessary nor sufficient for success, even in
corporate and governmental environments.
There is no Windows ISO standard, no Java ISO standard, and yet these
are used very widely. OTOH there is an ISO (or at least ANSI) CPU
standard (for a subset of the SPARC ABI, IIRC) which nobody cares about
and I think the Pascal or BASIC ISO standards are similarily
inconsequential. 

Successful standards (like C90 or POSIX) are developed after there have
been multiple implementations and when the implementors actually want to
converge on a single standard. In the case of an open source interpreted
language like perl5 there is little value in a standard. There is only
one implementation, a second implementation is unlikely to happen
(porting is almost always easier than rewriting from scratch) if it
happens compatibility is probably only a minor goal.

> A standard doesn't make ensure conformance.  While SOAP for example
> has a standard no one quite implements SOAP the same way, so we have a
> set of mutually incompatable programs each implementing there own
> subset of the protocol.

Same for SQL.

Even the current C standard is widely ignored. While most C compilers
implement C90, there are only 2 or 3 compilers which are certified
C99-conforming, and maybe a handful of others which try to be that. Most
C implementators either ignore C99 completely or implement only those
features which are either easy or demanded by their customers.

> Part of me would like a nice certificate to say "Perl's all mature and
> 'Enterpize ready'" but I fear the loss of @larry's guidence that this
> might entail.

Mostly I fear that would slow down perl development even more than the
combination of "we need to be backwards compatible" and "perl6 is just
around the corner" has done. ISO standards are usually revised every 10
years, and they are viewed as infallible. So if something is
standardized which is genuinely broken (which does happen), it will take
10 years before it is declared "deprecated" and 20 years before it is
removed from the language. With "normal" software development like in
perl the problem can be fixed in the next release (and hopefully by that
time there won't be much code which relies on it so the fix will cause
few problems).

	hp

-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


------------------------------

Date: Sat, 27 Oct 2007 11:57:55 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: perl time function
Message-Id: <slrnfi62t3.77r.hjp-usenet2@zeno.hjp.at>

On 2007-10-17 15:53, Ben Morrow <ben@morrow.me.uk> wrote:
>
> Quoth smallpond <smallpond@juno.com>:
>> On Oct 17, 9:33 am, lerameur <leram...@yahoo.com> wrote:
>> >
>> > I know there are lot of function in perl.
>> > Can somebody tell me which function does the following:
>> > I have the : year, month, day, hours   I want to increment the hours
>> > everytime the script is run. once the hours reaches 23 to 24 (actually
>> > 0), it will increment the days. My concerns are with leap years and
>> > months
>> 
>> Better to keep the time in seconds and use localtime to extract
>> year/month/day/hour.  Then you can just keep adding 3600 each
>> hour.  This way you don't have to reinvent what is probably the
>> most frequently reinvented wheel in application programming.
>
> Hours (or, at any rate, 'calendar hours') are not necessarily 3600
> seconds long, because of leap seconds. When doing calendar calculations,
> it's best to use a module that does it right.

When doing calendar calculations which may possibly include future dates
you cannot use leap seconds. Leap seconds are determined by observation
every six months, so at this point of time it is impossible to know how
many seconds the year 2008 will have. 

This is why POSIX timestamps don't use leap seconds. The POSIX timestamp
1199145600 always refers to 2008-01-01 00:00:00 UTC and the POSIX
timestamp 1230768000 always refers to 2009-01-01 00:00:00 UTC,
regardless of the number of actual seconds between these dates.

So, if you really need to know the number of seconds between two
timestamps, you can't just subtract them. OTOH, you can just add 3600 to
get to the next calendar hour, as smallpond suggested.

	hp


-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


------------------------------

Date: Sat, 27 Oct 2007 12:48:26 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl time function
Message-Id: <a5lbv4-051.ln1@osiris.mauzo.dyndns.org>


Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> On 2007-10-17 15:53, Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > Hours (or, at any rate, 'calendar hours') are not necessarily 3600
> > seconds long, because of leap seconds. When doing calendar calculations,
> > it's best to use a module that does it right.
> 
> When doing calendar calculations which may possibly include future dates
> you cannot use leap seconds. Leap seconds are determined by observation
> every six months, so at this point of time it is impossible to know how
> many seconds the year 2008 will have. 
> 
> This is why POSIX timestamps don't use leap seconds. The POSIX timestamp
> 1199145600 always refers to 2008-01-01 00:00:00 UTC and the POSIX
> timestamp 1230768000 always refers to 2009-01-01 00:00:00 UTC,
> regardless of the number of actual seconds between these dates.
> 
> So, if you really need to know the number of seconds between two
> timestamps, you can't just subtract them. OTOH, you can just add 3600 to
> get to the next calendar hour, as smallpond suggested.

OK, now I'm fascinated... what happens when a leap second occurs?
time(3) returns the same value for two seconds in a row? That sounds...
confusing, although I suppose it's similar to what adjtime(2) does...

[Spurious Perl connection: this is similar to the hobbit's system of
treating leap days as not part of the year... :)]

Ben



------------------------------

Date: Fri, 26 Oct 2007 20:19:46 -0700
From:  hendedav@gmail.com
Subject: Re: PID of exec
Message-Id: <1193455186.148813.169780@57g2000hsv.googlegroups.com>

On Oct 26, 4:37 pm, xhos...@gmail.com wrote:
> hende...@gmail.com wrote:
> > On Oct 26, 2:32 pm, xhos...@gmail.com wrote:
>
> > > > The top if statement only gets executed once (to start a process
> > > > which is monitored by the pollJob section), then the pollJob gets
> > > > called between 2-3 seconds until the job is done.  This job is only
> > > > running for 30 seconds (because of the test.sh script), but I
> > > > accumulate several many zombies.  Any ideas?
>
> > > Since the code you show only forks once and is only run once, it
> > > couldn't give rise to many zombies. The zombies must be coming from
> > > someplace else.
>
> > Actually I put some tracking in the script and I get a zombie for
> > every execution of that script.
>
> But isn't the part of your code that does the fork only executed once?
>
> > This last run executed 17 times and I
> > had 17 zombies.  That can't be good for the kernel if run over a long
> > period of time.
>
> What was run 17 times, the runner code or the monitor code?  The monitoring
> part of the code might be executed several times, but that part doesn't
> fork anything, right?
>
> Rather than having the runner and the monitor be the same script just with
> different parameters, make them be different scripts.  Then see which one
> is the zombie---the runner or monitor.
>
> 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.

You are correct that the fork'ed code only runs once and the other
section gets called repeatedly.  I think that everytime that script is
called (regardless of which section is executed) produces a zombie.  I
think it is the section that gets called repeatedly (that is the part
that I put the checking into).

Dave



------------------------------

Date: Fri, 26 Oct 2007 20:22:15 -0700
From:  hendedav@gmail.com
Subject: Re: PID of exec
Message-Id: <1193455335.640415.163860@v3g2000hsg.googlegroups.com>

On Oct 26, 4:26 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth hende...@gmail.com:
>
> > [snip] Also, this
> > script seems to be generating zombies.  Anyone have ideas on how to
> > clear that up?  I was hoping that the "local $SIG{CHLD} = "IGNORE";"
> > line would do the trick (as it stated in the perldoc's), but I guess
> > not.
>
> Setting SIGCHLD to IGNORE to clean up zombies is non-portable. Possibly
> your system doesn't have this behaviour: you will need to wait for your
> children yourself.
>
> Ben


Ben, thanks for the info on not being portable.  I would actually like
this code to work on Linux and Windows (I know I will have to make
changes to the way the PIDs are interacted with, but that will come
down the road).  The problem with waiting for the child to complete,
is that the client will timeout.  This is why I am trying to fork a
child process from the parent, so it can complete and the browser can
be doing other things.

Dave



------------------------------

Date: Sat, 27 Oct 2007 05:07:47 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: PID of exec
Message-Id: <j5qav4-378.ln1@osiris.mauzo.dyndns.org>


Quoth hendedav@gmail.com:
> On Oct 26, 4:26 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > Quoth hende...@gmail.com:
> >
> > > [snip] Also, this
> > > script seems to be generating zombies.  Anyone have ideas on how to
> > > clear that up?  I was hoping that the "local $SIG{CHLD} = "IGNORE";"
> > > line would do the trick (as it stated in the perldoc's), but I guess
> > > not.
> >
> > Setting SIGCHLD to IGNORE to clean up zombies is non-portable. Possibly
> > your system doesn't have this behaviour: you will need to wait for your
> > children yourself.
> 
> Ben, thanks for the info on not being portable.  I would actually like
> this code to work on Linux and Windows (I know I will have to make
> changes to the way the PIDs are interacted with, but that will come
> down the road).  The problem with waiting for the child to complete,
> is that the client will timeout.  This is why I am trying to fork a
> child process from the parent, so it can complete and the browser can
> be doing other things.

Using

    use POSIX qw/:sys_wait_h/;

    $SIG{CHLD} = sub { 1 while waitpid(-1, WNOHANG) > 0 };

should reap any children that exit before you do under any Unix (IIRC
perl handles the broken SysV non-reinstalled signal handlers itself
nowadays). Under Win32, fork is faked: it doesn't actually create a new
process, just a new thread in the perl process. exec from a
pseudo-process will spawn(3) the exec'd child and leave the thread
waiting for it exit, so 'zombies' will still accumulate but they will
just be unjoined threads inside the perl process, not anything visible
to the system, and will be cleaned up when perl exits. (Annoyingly it
appears to me that the Win32 fork emulation *doesn't* send SIGCHLD when
a pseudechild exits... can anyone on Win32 confirm this?)

In any case, under both Unix and Win32, once the parent has exitted the
system takes responsibility for cleaning up after the child. Under Unix,
init(8) cleans up for you, under Win32 processes (real OS processes, not
perl's pseudo-processes) don't have parents so they don't ever turn into
zombies.

[You mention Linux: Linux is a system which *does* provide the SIGCHLD =
IGNORE functionality, so if that's what you're testing under you have
some other problem.]

Ben



------------------------------

Date: Sat, 27 Oct 2007 13:08:35 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: TeX pestilence
Message-Id: <tc56i39488jef3vmkcc057fg2vkol4tp98@4ax.com>

On Fri, 26 Oct 2007 12:09:22 +0200, David Kastrup <dak@gnu.org> wrote:

>Is there a particular reason you elided all the detailed explanation I
>give?  First: I am one of the most renowned TeX hackers in the field,
>so don't try telling me that I don't know what I am talking about.  In

It's oh so funny to hear words that are so often barked by cranks and
trolls used this seriously and honestly!

>Secondly: only a complete idiot or somebody without any serious
>programming experience confuses "excellent programming language" with
>"Turing complete".  "Turing complete" is a statement about what kind

This going to become a .sig!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Sat, 27 Oct 2007 13:09:05 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: TeX pestilence
Message-Id: <v176i3lpb4l5pr84dmon599a6bqbv6r9mt@4ax.com>

On Fri, 26 Oct 2007 20:51:32 +0900, Gernot Hassenpflug
<gernot@nict.go.jp> wrote:

>> Is there a particular reason you elided all the detailed explanation I
>> give?  First: I am one of the most renowned TeX hackers in the field,
>                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>LOL

Well, he is!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Sat, 27 Oct 2007 11:32:50 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: UTF8 strings and filesystem access
Message-Id: <slrnfi61e2.77r.hjp-usenet2@zeno.hjp.at>

On 2007-10-15 17:03, Gary E. Ansok <ansok@alumni.caltech.edu> wrote:
> In article <slrnfh46l5.6q4.hjp-usenet2@zeno.hjp.at>,
> Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>On 2007-10-11 22:22, Gary E. Ansok <ansok@alumni.caltech.edu> wrote:
>>> In article <slrnfgt1r0.o12.hjp-usenet2@zeno.hjp.at>,
>>> Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>>>> Quoth ansok@alumni.caltech.edu (Gary E. Ansok):
>>>>>> 
>>>>>>   1)  $dir is encoded internally in UTF8 (even if $dir doesn't 
>>>>>>            contain any non-ASCII characters)
>>>>
>>>>Then why is it a wide string?
>>>
>>> It's read in using XML::Simple from a config file that does not
>>> contain any non-ASCII characters, or any encoding specification in
>>> the XML prolog (though adding "encoding='ISO-8859-1'" didn't help).
>>
>>> Now that I've dug a little deeper, I think upgrading some of our
>>> module versions may help avoid this problem -- a recent change to 
>>> XML::LibXML mentioned "strip-off UTF8 flag for consistent behavior 
>>> independent of document encoding".
>>
>>You omitted an important piece here: The entry reads 
>>"strip-off UTF8 flag with $node->toString($format,1) for consistent ..."
>>$node->toString returns a piece of XML, which always should be a series
>>of bytes, not characters. I haven't looked at the source code of
>>XML::Simple, but it probably uses $text->data or $node->nodeValue.

Why did you quote this paragraph? You don't seem to reply to it.

> I've worked around the problem by switching from XML::LibXML to
> XML::SAX::PurePerl as the underlying parser -- now, the string 
> read in from the configuration file no longer has the UTF8 flag
> set, and the problem does not appear.

Probably because you have now two bugs which cancel each other out.
The charset handling of XML::SAX::PurePerl is severely broken[0] - don't
use it.


> I still think it's a bug that a string that can successfully opendir()
> a directory, combined (including the appropriate separator) with a
> file name read in by readdir(), does not result in a string that can
> by used to open() or stat() the file.

I agree. However, the opendir() only worked accidentally in your code
because the directory name just happened to contain only characters <=
0x7F. If it had contained a character >= 0x80 (like the file name you
read) it would have failed, too. It is the nature of buggy code that it
appears to work sometimes. The real fix is to explicitely encode/decode
strings as required.

> Especially since the path appears correct when printed as part of an
> error message, and it's difficult to diagnose the problem without
> resorting to something like Devel::Peek.

I think that open should work the same whether the filename argument
is a wide or narrow string. But I'm not sure how it should behave: There
are arguments for viewing a file name as a sequence of bytes and for
viewing it as a sequence of characters. The latter is usually more
convenient, but it makes some tasks impossible (e.g., renaming files
with "illegal" byte sequences). Maybe we need the equivalent of IO
layers for filenames, too. Or at least a flag "take filename encoding
from the locale".

	hp

[0] Actually just outdated: The current release is older than perl 5.8,
    so it doesn't know about perl 5.8 Unicode support.

-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


------------------------------

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 982
**************************************


home help back first fref pref prev next nref lref last post