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

show code

hide dos windows

BEGIN { Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow +; }

Or hide on a per process basis use Win32::Process

Replies are listed 'Best First'.
Re^2: Wperl.exe fails with Tk + piped process ( Win32 )
by chessgui (Scribe) on Jan 09, 2012 at 12:52 UTC
    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.
        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.

      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.