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:
Problem with open2 & open3 in WinXP.

 



julmss
New User

Nov 4, 2009, 2:45 AM

Post #1 of 3 (4672 views)
Problem with open2 & open3 in WinXP. Can't Post

Hello, i have a problem with open2 and open3. Open work succesfully.

I porting my perl script from Linux to Windows. I realize many test and dont find any problem (executing calc.exe, perl script, etc) but three days ago problem starting with one executable.

The executable is a simulation program. It read a file specifiqued in command line parameter and write output files.

I used open3:
$childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd, @args);


The program start and freeze quickly. ¿Sleep? ¿Waiting by syscall? i dont know.


Screen capture of the three scenarios:
1) Capture when start and blocks (open2 and open3).
$pid = open2(\*CHLD_OUT, \*CHLD_IN, 'c:\madymo70.exe');
print "EXE\n"; #this dont show
waitpid(-1,WNOHANG);
print "FINAL\n";
(File: block on start.jpg)

2) Capture when start correctly (open)
$pid = open(HANDLE, "|C:/madymo70.exe|");
#PROBLEM: ¡¡¡¡¡¡¡continue when program finnish!!!!!!!!
print "EL PID ES: $pid";
waitpid(-1,0);
print "FIN\n";
(File: ok when used open.jpg)
3) Win32::Process::Create work ok but ¿How could i capture stdout and stderr?.

I need start program in background while perl script continue. Perl script check if program finish and connect to database.

Somebody have an idea why it work don't fine?


(This post was edited by julmss on Nov 4, 2009, 5:54 AM)
Attachments: ok when used open.jpg (61.1 KB)
  block on start.jpg (51.9 KB)


FishMonger
Veteran / Moderator

Nov 4, 2009, 8:44 AM

Post #2 of 3 (4659 views)
Re: [julmss] Problem with open2 & open3 in WinXP. [In reply to] Can't Post

Have you tried passing references or lexical vars?

change:

Code
$childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd, @args);

to:

Code
$childpid = open3(\*HIS_IN, \*HIS_OUT, \*HIS_ERR, $cmd, @args);


or:

Code
open3($writer, $reader, $error, $cmd, @args);



julmss
New User

Nov 4, 2009, 9:28 AM

Post #3 of 3 (4654 views)
Re: [FishMonger] Problem with open2 & open3 in WinXP. [In reply to] Can't Post

Thank you for your post.

Yes,I tried it.

After many many hours, open2 and open3 work ->IF I READ TWO LINES FROM STDOUT<-:

$program="C:/Madymo/madymo_70/win32p/bin/madymo70.exe c:/W62_DAB.xml";
($reader, $writer) = (IO::Handle->new, IO::Handle->new);
open2($reader, $writer, $program);
print "----> ".<$reader>."\n";
print "----> ".<$reader>."\n";

waitpid(-1,0);

This work!

I don't understand. Why if i read two lines or more from stdout the process continue? I probe to write stdin (the process dont read stdint) but not read from stdout.

Very thank you

 
 


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

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