By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

Win32::Process, console & threads

P: 3
Hi all ,

I have a perl/java app running under Win32. The application consists of a perl service (Win32::Daemon) and of java classes. The perl service calls every xx hours java classes to perform some action.

The java call looks like this:

Expand|Select|Wrap|Line Numbers
  1. Win32::SetChildShowWindow(0);
  2.  
  3. Win32::Process::Create(
  4.     $ProcessObj,
  5.     $javaExe,
  6.     $commandArgs,
  7.     0,
  8.     Win32::Process::NORMAL_PRIORITY_CLASS|Win32::Process::CREATE_NO_WINDOW,
  9.     $installPath
  10. ) or $retCode = -9;
  11.  
The point of SetChildShowWindow(0) and CREATE_NO_WINDOW is to hide the console window that perl usually displays when creating new process.

This worked fine until I tried to run the same code inside a thread.

I now have a perl module JavaCall.pm with "static" subs calling the java classes.
My perl service starts a thread each time it needs to call java (if the java process is not started inside a thread, the perl service does not get the shutdown event until the java process finishes).

So I have something like this:

perlservice.pl:
Expand|Select|Wrap|Line Numbers
  1. sub Callback_Running {
  2.     $runningThread = threads->new(\&startProcess, $installPath, $executePath, $configFile, $parser, $logger, $configref, $Context);
  3.     $runningThread->detach();
  4. }
  5.  
  6. sub startProcess {
  7.     JavaCall->callJavaClass(...);
  8. }
  9.  
JavaCall.pm:

Expand|Select|Wrap|Line Numbers
  1. Win32::SetChildShowWindow(0);
  2. Win32::Process::Create(
  3.     $ProcessObj,
  4.     $javaExe,
  5.     $commandArgs,
  6.     0,
  7.     Win32::Process::NORMAL_PRIORITY_CLASS|Win32::Process::CREATE_NO_WINDOW,
  8.     $installPath
  9. ) or $retCode = -9;
  10.  
And here is the mistery: This works perfect under my Windows XP SP2 Profesional Edition, English. But the console "cmd.exe" shows up on a Windows XP SP2 Home Edition, French.
I do not know yet if this problem is specific to Home or French edition.

This app is distributed on users PC and I cannot have that window showing up.
Any help greatly appreciated.

Jerome
May 15 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.