Link to home
Start Free TrialLog in
Avatar of ravenpl
ravenplFlag for Poland

asked on

Why this will not finish?

I have this trivial(i thought) script run under windows with ActiveStatePerl. The problem with this script is that it will not finish.
The console is opened and never closed automatically.

#!/usr/bin/perl
#open(STDIN, "</dev/null"); # how should I do it under windows?
#open(STDOUT, ">/dev/null");
#open(STDERR, ">/dev/null");

if (0 == fork()) #child
{
      chdir('C:\Program Files\Mozilla Thunderbird');
      exec {'C:\Program Files\Mozilla Thunderbird\thunderbird.exe'} 'thunderbird' || die;
}

if (0 == fork()) #child
{
      sleep(10);
      chdir('C:\Program Files\Mozilla Firefox');
      exec {'C:\Program Files\Mozilla Firefox\firefox.exe'} 'firefox' || die;
}

exit(0);
Avatar of farzanj
farzanj
Flag of Canada image

So what is happening.

What I see is that it is making two sub-processes one opens thunderbird and the second one opens firefox.

You simply have nothing to end or destroy the objects.

What do you want to do?
Avatar of ravenpl

ASKER

> What do you want to do?
I want to spawn two subprocesses and terminate the father. However the terminal window will not shut itself. Like it ignores the exit() statement.
Additionally, if TB abd FF are already running, the perl window shuts as expected.
ASKER CERTIFIED SOLUTION
Avatar of group0
group0

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial