How the scrip can continue
How the scrip can continue
am 03.11.2007 16:59:35 von Petr Vileta
I wrote simple script stared from Apache. This do something few seconds and
at the end send mail somewhere. All works fine if I don't press Cancel
button in browser. But I need a script to continue in work regardles of http
connection is alive or canceled. I set my $SIGs but without success. Know
anybody what signal Apache send to perl scripts when user cancel connection?
-------------- test.cgi ------------------
#!/usr/bin/perl
use strict;
$|=1;
our $sig='';
$SIG{'QUIT'}=sub {$sig='QUIT';};
$SIG{'TERM'}=sub {$sig='TERM';};
$SIG{'PIPE'}=sub {$sig='PIPE';};
$SIG{'ABRT'}=sub {$sig='ABRT';};
$SIG{'HUP'}=sub {$sig='HUP';};
$SIG{'KILL'}=sub {$sig='KILL';};
$SIG{'STOP'}=sub {$sig='STOP';};
$SIG{'ALRM'}=sub {$sig='ALRM';};
$SIG{'BREAK'}=sub {$sig='BREAK';};
$SIG{'STOP'}=sub {$sig='STOP';};
$SIG{'__DIE__'}=sub {$sig='__DIE__';};
my $sendmail='/usr/sbin/sendmail';
print "Content-Type: text/html\n\n
Sending mail, please wait";
foreach (1..10)
{
print $_ . ' 'x512;
sleep 3;
}
send_mail($sendmail, 'Hurry');
print "
Done.\n";
sub send_mail
{
my ($sendmail,$msg)=@_;
# here is send mail somewhere
}
-------------- test.cgi ------------------
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Re: How the scrip can continue
am 03.11.2007 17:43:13 von jurgenex
Petr Vileta wrote:
> $SIGs but without success. Know anybody what signal Apache send to
> perl scripts when user cancel connection?
I would suggest you ask in a NG that actually deals with Apache and web
servers. Chances are people there know much more about Apache than here.
jue
Re: How the scrip can continue
am 03.11.2007 18:27:42 von Michele Dondi
On Sat, 3 Nov 2007 16:59:35 +0100, "Petr Vileta"
wrote:
>I wrote simple script stared from Apache. This do something few seconds and
>at the end send mail somewhere. All works fine if I don't press Cancel
>button in browser. But I need a script to continue in work regardles of http
>connection is alive or canceled. I set my $SIGs but without success. Know
>anybody what signal Apache send to perl scripts when user cancel connection?
I think you could adapt the technique described in
instead. That
is, fork a process to do the actual job.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: How the scrip can continue
am 04.11.2007 02:09:32 von xhoster
"Petr Vileta" wrote:
> I wrote simple script stared from Apache. This do something few seconds
> and at the end send mail somewhere. All works fine if I don't press
> Cancel button in browser. But I need a script to continue in work
> regardles of http connection is alive or canceled. I set my $SIGs but
> without success. Know anybody what signal Apache send to perl scripts
> when user cancel connection?
I've heard rumors that it sends a TERM; followed shortly after by an
untrappable KILL, if necessary.
Fork and have the child do the work. If the parent gets killed the child
will probably continue. (For unix-like OSes)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
Re: How the scrip can continue
am 04.11.2007 03:32:02 von Petr Vileta
xhoster@gmail.com wrote:
> "Petr Vileta" wrote:
>> I wrote simple script stared from Apache. This do something few
>> seconds and at the end send mail somewhere. All works fine if I
>> don't press Cancel button in browser. But I need a script to
>> continue in work regardles of http connection is alive or canceled.
>> I set my $SIGs but without success. Know anybody what signal Apache
>> send to perl scripts when user cancel connection?
>
> I've heard rumors that it sends a TERM; followed shortly after by an
> untrappable KILL, if necessary.
>
I will try to write some to file in these two SIGs hacked to my routines.
> Fork and have the child do the work. If the parent gets killed the
> child will probably continue. (For unix-like OSes)
>
This is a problem. My script must run on *nix and Win OS too. On both are
Appache running, but on Win platform fork not work correctly (here is
emulated only). Above this my script is a "fat boy" ;-) and if I know right
the fork create a copy of script, right?
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Re: How the scrip can continue
am 04.11.2007 06:59:15 von Ben Morrow
Quoth "Petr Vileta" :
> xhoster@gmail.com wrote:
> > "Petr Vileta" wrote:
> >> I wrote simple script stared from Apache. This do something few
> >> seconds and at the end send mail somewhere. All works fine if I
> >> don't press Cancel button in browser. But I need a script to
> >> continue in work regardles of http connection is alive or canceled.
> >> I set my $SIGs but without success. Know anybody what signal Apache
> >> send to perl scripts when user cancel connection?
> >
> > I've heard rumors that it sends a TERM; followed shortly after by an
> > untrappable KILL, if necessary.
> >
> I will try to write some to file in these two SIGs hacked to my routines.
Note that you can't handle SIGKILL (that's the point).
> > Fork and have the child do the work. If the parent gets killed the
> > child will probably continue. (For unix-like OSes)
> >
> This is a problem. My script must run on *nix and Win OS too. On both are
> Appache running, but on Win platform fork not work correctly (here is
> emulated only).
Put the bulk of the work in a separate script and run it with
system(1, ...) (see FUNCTION IMPLEMENTATIONS/system in perlport) or
Win32::Process.
> Above this my script is a "fat boy" ;-) and if I know right
> the fork create a copy of script, right?
Under Unix, not in any meaningful sense. The copy starts out sharing
everything with its parent, and only things that you modify are copied.
Ben