Re: Is this possible in Perl?
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 12 Jul 2008 15:25:29 GMT
Bill H <bill@xxxxxxxxx> wrote:
I have a perl routine that takes some html form variables that are
"POST"ed to it from a Flash app (works the same as a web page POST)
and when it is done it sends back a status to the Flash program using
a simple:
print "Content-type:text/plain\n\n";
print "status=complete";
Perhaps things will already work when you append a "\n" to that
last line? It could happen that a line without a trailing new-
line gets stuck in some internal buffers and only gets send to
the parent process when your script exits and all open files are
closed after the buffers are flushed. Or do
$| = 1;
to make sure stdout is unbuffered.
exit;
which works fine. What I would like to do is send the above so that
the Flash app goes about its business but have the perl program
continue on doing some stuff that I don't want the user to have to
wait for the completion of. What I am looking for is a way to simulate
whatever perl does for the waiting user when it performs the exit
without exiting. Something like this:
print "Content-type:text/plain\n\n";
print "status=complete";
"some magical perl command to force the above to the user
and end connection without stopping program"
additional code that is executed
exit;
If appending a newline to the last line of ouput or setting
auto-flushing for stdout doesn't do the job I guess it's only
in parts a Perl issue and involves also the behaviour of the
process that started the Perl script. The question is: is what
the process that started your script waiting for. Is it waiting
for the stdout of yor script to become closed or is it waiting
for your script to exit? That would seem to me the most likely
scenarios. Thus you could try to do what that process is waiting
for, i.e. in the first case close stdout (and perhaps stderr)
and in the second fork() (to get a new process) and exit in the
parent process. I would try something like this:
close STDIN;
close STDERR;
exit 0 if fork;
The first two lines close stdin and stderr, just to make sure
all buffers are flushed, and the last one ends the parent pro-
cess while creating a new process for continuing with whatever
you still may have to do. If that works you can try if leaving
out the fork() also works. (But note: that's from a UNIX per-
spective, I have no idea how things work under Windows..)
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: Is this possible in Perl?
- From: Bill H
- Re: Is this possible in Perl?
- References:
- Is this possible in Perl?
- From: Bill H
- Is this possible in Perl?
- Prev by Date: Re: How can I use constants?
- Next by Date: remove previous lines of a log file
- Previous by thread: Is this possible in Perl?
- Next by thread: Re: Is this possible in Perl?
- Index(es):
Relevant Pages
|