in reply to Re: Wperl.exe fails with Tk + piped process ( Win32 )
in thread Wperl.exe fails with Tk + piped process ( Win32 )

If I use SetChildShowWindow(SW_HIDE) wperl.exe won't open the console window for the piped process but the app itself crashes anyway (in fact NO code following the Open2 seems to be processed - it simply freezes at that point). Your second solution won't work since $cflags (creation flags, like CREATE_NO_WINDOW) can only be passed to a Win32::Process object if the process is created by Win32::Process::Create. If you create a process from a pid through Win32::Process::Open $cflags can not be passed (therefore you can't shut down a window created by Open2 or the window of the script itself).

Let's put it simply: wperl.exe crashes with an Open2 call under Win32, perl.exe on the other hand always opens a console window whether there are child processes or not.
  • Comment on Re^2: Wperl.exe fails with Tk + piped process ( Win32 )

Replies are listed 'Best First'.
Re^3: Wperl.exe fails with Tk + piped process ( Win32 )
by Anonymous Monk on Jan 09, 2012 at 23:09 UTC
      Now this post has been useful. Thanks a lot.

      Unfortunately I could not test the Win32::GUI solution (since I can't build Win32::GUI due to make errors), but luckily there is an example code which does the same in slightly more complicated way by using Win32::API (which installs on my system seamlessly).

      This latter code works for me after some massaging. Though the consolde window is created but is shut down immediately.

      Thanks again, this is a perfect solution.

        You know, its trivial to create a tiny gui win32 .exe, which sets up all the console hiding stuff, and then launches a hidden perl.exe as opposed to wperl.exe

        or you could simply use wperl.exe , call the hiding children function, then launch a hidden perl.exe

Re^3: Wperl.exe fails with Tk + piped process ( Win32 )
by Anonymous Monk on Jan 09, 2012 at 22:41 UTC

    wperl.exe won't open the console window for the piped process but the app itself crashes anyway

    So you say again :) Maybe you'd like to prove it by posting some code?

      This code will create a text file called 'test.txt' with the content 'I'm alive' both with perl.exe and wperl.exe:

      use IPC::Open2; #$pid = open2( \*Reader, \*Writer, "notepad.exe" ); open OUTF, ">test.txt"; print OUTF "I'm alive"; close OUTF;


      Now, the following code will do the same (+open a window for notepad.exe) with perl.exe but will FAIL with wperl.exe (the notepad window is opened but NO text file is created). The only difference is that now the Open2 call is not commented out:

      use IPC::Open2; $pid = open2( \*Reader, \*Writer, "notepad.exe" ); open OUTF, ">test.txt"; print OUTF "I'm alive"; close OUTF;


      To me this is proof that with wperl.exe the execution is aborted at the Open2 call.

        I doubt that a wperl process has STDIN and STDOUT connected. I think that IPC::Open2 tries to do fancy things with (an existing) STDIN and STDOUT.

        Personally, I would try to avoid IPC::Open2 and/or pipe functionality, at least until after having set up STDIN and STDOUT for the child process.