in reply to Execute as new process?
lower level approaches:
system and qx// are synchronous and make perl wait until the syscall in question is done. You could try system("cmd&") to have the shell run the command and return to perl w/o waiting.
An interesting question now is whether you want $? or the output of the command before finishing to send the page to the client. If that's the case: check out e.g. waitpid, perlipc and maybe also use something like the following sketch
if (not fork()) {system("cmd >cmd-out"); ... exit} ...additionalprocessing-in-parallel...; wait; # or a more specific waitpid...; # if you've a lot of forks and/or run a long time, # consider to reap your children: wait, SIG{CHLD} # -> man perlipc open(FH,"<cmd-out");... ...process the results of cmd and add them to the page... # (or consider a state file/sessions, if the background # command can and should run for more than the duration # of a single client request) finish the page
|
|---|