CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
Background child with pid on windows

 



e-Dough
New User

Jan 27, 2009, 11:56 PM

Post #1 of 4 (4442 views)
Background child with pid on windows Can't Post

Hi,

I'm converting an existing Perl script from UNIX to Windows XP.

This script calls another Perl script in the background using backticks and ampersand (`x_child.pl ... &`).
The child script acts as a timeout check for the parent and will kill it if it's stuck for too long.
Eventually, the parent will also kill the child script - using the shell's `ps -ef | grep x_child.pl ...` to locate the child's PID.

I need to replicate this behaviour under windows but wasn't able to find the tools:

1. using 'system(1, "perl x_child.pl...")' the script runs in the background, but I can't get it's PID.

2. using 'tasklist' doesn't seem to get the program's arguments to enable identifying a specific instance, or even the script's name (only 'perl.exe').

3. using 'open(GET_PID, "perl x_child.pl ...|")' I can communicate with the process and have it send back it's PID, but I can't have it run in the background.

('...' meaning script arguments)

Any ideas ?


FishMonger
Veteran / Moderator

Jan 28, 2009, 6:05 AM

Post #2 of 4 (4439 views)
Re: [e-Dough] Background child with pid on windows [In reply to] Can't Post

You're using the wrong approach.


Quote
C:\>perldoc -q timeout
Found in C:\Perl\lib\pods\perlfaq8.pod
How do I timeout a slow event?
Use the alarm() function, probably in conjunction with a signal handler,
as documented in "Signals" in perlipc and the section on "Signals" in
the Camel. You may instead use the more flexible Sys::AlarmCall module
available from CPAN.

The alarm() function is not implemented on all versions of Windows.
Check the documentation for your specific version of Perl.



e-Dough
New User

Feb 8, 2009, 1:41 AM

Post #3 of 4 (4400 views)
Re: [FishMonger] Background child with pid on windows [In reply to] Can't Post


In Reply To
You're using the wrong approach.


Quote
C:\>perldoc -q timeout
Found in C:\Perl\lib\pods\perlfaq8.pod
How do I timeout a slow event?
Use the alarm() function, probably in conjunction with a signal handler,
as documented in "Signals" in perlipc and the section on "Signals" in
the Camel. You may instead use the more flexible Sys::AlarmCall module
available from CPAN.

The alarm() function is not implemented on all versions of Windows.
Check the documentation for your specific version of Perl.




Thanks.

This is a great solution and I learned something new.

However, I am currently limited to using Perl version 5.0.5, where alarm() is not supported.

Any other ideas are greatly welcome.


FishMonger
Veteran / Moderator

Feb 8, 2009, 7:25 AM

Post #4 of 4 (4395 views)
Re: [e-Dough] Background child with pid on windows [In reply to] Can't Post

That version is circa '98-'99 and while it's plausible that's what is installed on your UNIX system, it's highly unlikely that you have that old of a version on the XP box.

Any/every proper solution is going to involve upgrading perl to a newer version, preferably 5.8.8 or 5.10 but nothing under 5.8.0.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives