?
Solved

Create process, don't wait

Posted on 2000-04-08
5
Medium Priority
?
812 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
  • 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans
Suggested Courses

850 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