Solved

Create process, don't wait

Posted on 2000-04-08
5
806 Views
Last Modified: 2012-05-04
Does Perl have a way to create another process that works on both Win32 and Unix? I dont want to wait on the newly created process.
0
Comment
Question by:rj2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Author Comment

by:rj2
ID: 2695995
Adjusted points from 200 to 300
0
 
LVL 5

Expert Comment

by:pitonyak
ID: 2696095
I had an application where I wanted to kick off a process to run in the background on Perl and I also wanted to grab the output.  To do this, I wrote a batch file that ran under windows and used the start command to kick off a process in the background and I wrote a ksh script that ran under unix which simply ran the program in the background.

In my perl code I then checked to see if my OS was MSWIN32 (I think this is what it is called)

if ($^O eq "MSWIN32") {
  system('mybatch.bat');
} else {
  system('myshell.ksh');
}

Or something like that. If you have the latest PERL for windows it may support the fork() function which is really what you want but it is newly supported on windows.

I can probably provide a better code example if it is really required but I have to go looking for it..

Andy
0
 
LVL 10

Author Comment

by:rj2
ID: 2696256
Adjusted points from 300 to 500
0
 
LVL 10

Author Comment

by:rj2
ID: 2696257
One important addition:
It'a a CGI script.
I sometimes regenerate some files. This take some time. I want to return results based on the existing files and
start another independent process that does the regeneration, so the user don't have to wait.

I tried using fork, but when I ran it in the browser, it still waited until the other process had finished, also if the child called POSIX::setsid.

Is there a way around this?
It's enough that it works on Unix.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 2696754
Close STDOUT (that should effectively end the CGI scripts communication with the client) and then start the regeneration.

e.g.,

# Display your page based on current files
print "Content-type: text/html\n\n";
print "<HTML><BODY>Page Content</BODY></HTML>";

# flush and close STDOUT, ending communication
close STDOUT;

# Do regeneration tasks...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question