in reply to PAR pp Windows 2 instances

Its been awhile since I generated an exe with GUI on Windows - the last major release was on XP. The default was a command line task that shows STDOUT/STDERR and then a task for the GUI itself (much bigger).

With PerlApp, there was an option to eliminate this extra task that when maximized shows command line output. I guess that you are using pp? I suspect that there is a similar "launch option". If there is not, then it is possible to write some Perl code to launch your app as a "detached process", meaning that there is no command line. From my previous testing this is about 1/2 page of Perl. Look for a compile option in pp. From my memory on WinXP, killing the command line task also killed the GUI. Windows is a complicated beast - I have no idea why that doesn't work on Win10.

Update:
I was trying to kill my application from outside Perl (to perform an update which requires my application to be killed)
I can't even imagine intentionally doing such a thing. My gosh you are describing something that would be a program crash! I mean as a user if I'm using the GUI and then all of a sudden "poof", the program dies, I'd be pretty upset!! Internally within the main application code, a "kill" command from the OS will likely cause some data loss.

I have tested Perl signal handlers under Windows - I don't remember exactly how, but there has got to be some better way for your update process to work. Issuing a "kill" at a random moment during user GUI interaction is "BAD, VERY BAD".

Update:
If you don't want the command line task, something similar to this should work. I got this from one of my Perl books and I remember testing something close to this in the past. This code does appear in a copyrighted book, but it is so short that I think "fair use" applies because it just shows how to use Win32::Process::Create().

#!/usr/bin/perl -w # loader - starts Perl scripts without the annoying DOS window use strict; use Win32; use Win32::Process; # Create the process object. Win32::Process::Create($Win32::Process::Create::ProcessObj, 'C:/perl5/bin/perl.exe', # Whereabouts of Perl 'perl realprogram', # 0, # Don't inherit. DETACHED_PROCESS, # ".") or # current dir. die print_error(); #or perhaps, just die "some error msg"; #consider using the START command in a Windows batch file sub print_error() { return Win32::FormatMessage( Win32::GetLastError() ); }

Replies are listed 'Best First'.
Re^2: PAR pp Windows 2 instances
by IB2017 (Pilgrim) on Feb 04, 2019 at 08:18 UTC

    Thank you for pointing me to the Console issue (I use the -g option to prevent the Console, but I need to look in this matter). As far as the process killing is concerned: well, it sounds bad as I formulated it, but it is not. It is an update process guided by the user by means of a wizard. The user is prompted that the application will be closed before updating (the operation is necessary as the .exe needs to be replaced by the updater).

      I don't know about pp and the -g option, but I'm sure that other folks here do know about that. I don't know why there would be 2 PID's unless some kind of console is running? In my previous GUI's using PerlApp, there was only one process if I didn't allow a command line window.

      This does prompt me into thinking about more PerlApp testing... As far as I know, you cannot buy an Active State license for Perl App anymore? This used to be part of their "Perl Dev Kit". I have a legacy license and I am able to maintain that license as long as my yearly payments don't lapse. To my knowledge, Active State does not sell licenses for anything to "small shops" anymore. First payment starts at $1,500? This used to be a $100 one time fee.

      Back in the day, computer hardware was very expensive. My boss got me the $750 for full Active State licensing including the Komodo dev environment. But I could not get the $3K worth of hardware to run it! At the end of the day, I used the $100 Perl Dev Kit and most of our money was plain wasted because the hardware to run the dev environment S/W was so damn expensive. I'm sure that has changed nowadays.

        You are right. PerlApp is no more available (I wrote them 1 y ago), which is a shame as it used to work perfectly, at least in all my past projects.