You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Gary Denslow <ga...@yahoo.com> on 2003/12/30 20:23:55 UTC
[mp1] signal handler for USR2 in startup.pl doesn't work
a signal handler for USR2 has been setup in startup.pl, but sendinga USR2 to the root httpd process does not result in the execution of the signal handler; apache: 1.3.29; mod_perl: 1.29; perl: 5.8.2;#################################################################output of uname -aLinux localhost.localdomain 2.4.20-6 #1 Thu Feb 27 09:35:54 EST 2003 i586 i586 i386 GNU/Linux#################################################################perl -V output:Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration: Platform: osname=linux, osvers=2.4.20-6, archname=i586-linux uname='linux localhost.localdomain 2.4.20-6 #1 thu feb 27 09:35:54 est 2003 i586 i586 i386 gnulinux ' config_args='-de' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O3', cppflags='-fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.3.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared
-L/usr/local/lib'Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under linux Compiled at Dec 28 2003 17:22:53 @INC: /usr/local/lib/perl5/5.8.2/i586-linux /usr/local/lib/perl5/5.8.2 /usr/local/lib/perl5/site_perl/5.8.2/i586-linux /usr/local/lib/perl5/site_perl/5.8.2 /usr/local/lib/perl5/site_perl .#################################################################no options given to mod_perl's Makefile.PL#################################################################relevant mod_perl server configuration: AddHandler perl-script Apache::RegistryPerlRequire /usr/local/apache/conf/startup.pl<Location /perl-status> SetHandler perl-script PerlHandler Apache::Status order deny,allow deny from all allow from 127.0.0.1 </Location>PerlFreshRestart Onnote that an access of /perl-status Signal Handler's sections shows:USR2 =
CODE(0x8221780)#################################################################error_log:[Sun Dec 28 20:10:07 2003] [notice] Apache/1.3.29 (Unix) mod_perl/1.29 configured -- resuming normal operations[Sun Dec 28 20:10:07 2003] [notice] Accept mutex: sysvsem (Default: sysvsem)#################################################################make test for mod_perl:(cd ../apache_1.3.29/src && PERL5LIB=/usr/local/src/mod_perl-1.29/lib: make CC="cc";)make[1]: Entering directory `/usr/local/src/apache_1.3.29/src'===> regexmake[2]: Nothing to be done for `all'.<=== regex===> os/unixmake[2]: Nothing to be done for `all'.<=== os/unix===> apmake[2]: Nothing to be done for `all'.<=== ap===> mainmake[2]: Nothing to be done for `all'.<=== main===> lib===> lib/expat-litemake[3]: Nothing to be done for `all'.<=== lib/expat-lite<=== lib===> modules===> modules/standardmake[3]: Nothing to be done for `all'.<=== modules/standard===> modules/perlmake[3]: Nothing to be done for `all'.<===
modules/perl<=== modulescc -c -I./os/unix -I./include -DLINUX=22 -DUSE_HSREGEX -DUSE_EXPAT -I./lib/expat-lite -DNO_DL_NEEDED -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DMOD_PERL modules.ccc -c -I./os/unix -I./include -DLINUX=22 -DUSE_HSREGEX -DUSE_EXPAT -I./lib/expat-lite -DNO_DL_NEEDED -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DMOD_PERL buildmark.ccc -DLINUX=22 -DUSE_HSREGEX -DUSE_EXPAT -I./lib/expat-lite -DNO_DL_NEEDED -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DMOD_PERL \ -o httpd buildmark.o modules.o modules/perl/libperl.a modules/standard/libstandard.a main/libmain.a ./os/unix/libos.a ap/libap.a regex/libregex.a lib/expat-lite/libexpat.a `/usr/local/bin/perl /usr/local/src/mod_perl-1.29/src/modules/perl/ldopts ` -lm -lcryptmake[1]: Leaving directory `/usr/local/src/apache_1.3.29/src'make[1]: Entering directory
`/usr/local/src/mod_perl-1.29/Apache'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Apache'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Connection'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Connection'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Constants'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Constants'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/File'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/File'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Leak'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Leak'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Log'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Log'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/ModuleConfig'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/ModuleConfig'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/PerlRunXS'make[1]: Leaving directory
`/usr/local/src/mod_perl-1.29/PerlRunXS'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Server'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Server'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Symbol'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Symbol'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Table'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Table'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/URI'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/URI'make[1]: Entering directory `/usr/local/src/mod_perl-1.29/Util'make[1]: Leaving directory `/usr/local/src/mod_perl-1.29/Util'../apache_1.3.29/src/httpd -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t &httpd listening on port 8529will write error_log to: t/logs/error_logletting apache warm up...\cdone/usr/local/bin/perl t/TEST 0still waiting for server to warm
up...okokokokmodules/actions.......okmodules/cgi...........okmodules/constants.....okmodules/cookie........skipped all skipped: no reason givenmodules/file..........skipped all skipped: no reason givenmodules/httpdconf.....okmodules/include.......okmodules/log...........skipped all skipped: no reason givenmodules/module........skipped all skipped: no reason givenmodules/perlrun.......okmodules/psections.....skipped all skipped: no reason givenmodules/request.......skipped all skipped: no reason givenmodules/src...........okmodules/stage.........skipped all skipped: no reason givenmodules/status........okmodules/symbol........skipped all skipped: no reason givenmodules/uri...........skipped all skipped: no reason givenmodules/util..........skipped all skipped: no reason
giveninternal/api..........okinternal/auth.........okinternal/croak........okinternal/dirmagic.....okinternal/error........okinternal/headers......okinternal/hooks........okinternal/http-get.....okinternal/http-post....okinternal/proxy........okinternal/redirect.....okinternal/rwrite.......okinternal/stacked......skipped all skipped: no reason giveninternal/table........skipped all skipped: no reason giveninternal/taint........okAll tests successful, 12 tests skipped.Files=33, Tests=271, 76 wallclock secs (64.30 cusr + 5.01 csys = 69.31 CPU)kill `cat t/logs/httpd.pid`rm -f t/logs/httpd.pidrm -f t/logs/error_log
#################################################################
startup.pl:
#!/usr/bin/perl
$SIG{USR2} = sub {
open(F,">>/logs/test_log") || die "can't append to test_log: $!";
my $l = localtime();
print F "$l [debug]: in USR2 handler\n";
close(F);
};
1;
Re: [mp1] signal handler for USR2 in startup.pl doesn't work
Posted by Torsten Foertsch <to...@gmx.net>.
On Tuesday 30 December 2003 22:35, Gary Denslow wrote:
> anyway, the signal handler is working on solaris. my problem is that on my
> linux setup the signal handler is being completely ignored. i send a USR2
> to the root httpd process and the signal handler is not executed at all...
I think your problem is perl's safe signal handling introduced in 5.8.0 or so.
I have tried
<PERL>
$SIG{USR2}=sub {
warn "USR2: @_: $$";
};
</PERL>
in my httpd.conf with 5.8.0 and 5.005_3 on linux. With 5.8.0 I get the message
from the signal handler only at server shutdown. With 5.005_3 it appears
immediately.
With 5.8.0 signals are delivered only between opcodes. Since apache's main
loop looks to perl like a very long running opcode the signal is delivered
only at shutdown.
Maybe you can achieve your goal using POSIX::sigaction. I haven't tried it.
Torsten
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: [mp1] signal handler for USR2 in startup.pl doesn't work
Posted by Gary Denslow <ga...@yahoo.com>.
hey ged
yestserday i saw the post that you referenced. if i understand that post, the user was noticing that when the initial httpd process is started, it forks to create another httpd root process. the PID for this 2nd root httpd process is written to the webserver's PID file and this 2nd root httpd process then spawns the children to handle requests. when a USR2 is sent to this 2nd root httpd process, the logging in startup.pl shows that the PID that rec'd the USR2 was the initial root process (which no longer appears as an active process in the process table) rather than the 2nd root httpd process. definitely confusing.
in my testing, i see the same situation happening on a solaris machine: the initial root httpd process forks to create a 2nd root httpd process, the PID for 2nd root httpd is written to the webserver's PID file; startup.pl has a USR2 sig handler that logs the PID of the receiving process; when i send a USR2 to this 2nd root httpd process, the handler is executed and i see that the receiving PID is actually the initial root PID which isn't visible in the process table.
anyway, the signal handler is working on solaris. my problem is that on my linux setup the signal handler is being completely ignored. i send a USR2 to the root httpd process and the signal handler is not executed at all...
Re: [mp1] signal handler for USR2 in startup.pl doesn't work
Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,
On Tue, 30 Dec 2003, Gary Denslow wrote:
> a signal handler for USR2 has been setup in startup.pl, but sending
> a USR2 to the root httpd process does not result in the execution of
> the signal handler
> apache: 1.3.29; mod_perl: 1.29; perl: 5.8.2
I think signal handling is a bit of a minefield in mod_perl.
Have a look for example at
http://www.gossamer-threads.com/perl/mailarc/gforum.cgi?post=31177;search_string=%22signal%20handler%22;guest=1908981&t=search_engine#31177
Have fun!
73,
Ged.
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html