perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject $? and "No child processes" in $! from `echo something` under mod_perl after a while...
Date Tue, 10 Sep 2002 16:20:47 GMT

For some reason, the process running mod_perl gets into a state, where it
doesn't behave properly with backticks after having run for a while. In
short, I'm confused about the relationship between SIG{CHLD}, qx and

#!/usr/bin/perl -w
use strict;

print "Content-type: text/html\n\n";

# $SIG{'CHLD'} = '';
my $sigChldStr;
if (defined $SIG{'CHLD'}) {
  $sigChldStr = (($SIG{CHLD} eq '') ? "empty" : "defined" );
} else {
  $sigChldStr = "undef";

my $result = `echo Result is something`;

if ($?) {
  print "Error: $?, $!, " . ($! + 0) . ", $result, " . $sigChldStr;
} else {
  print "Result: $result," . $sigChldStr;
print "\n";

When I run the script the first time, after a fresh reboot or restart of
apache, it runs fine. After a while of running my "real" application (2
days, 1 day, 4 hours - it varies) , the short script above (and my "real"
application") all of a sudden start failing consistently and $? after a
{ $result = `echo Result is something` } becomes true, with $! == "No child
processes" (This comes from wait(2), I suspect.). This result now happens
every time i hit refresh.

If I uncomment the $SIG{'CHLD'} = '' line and run it only once pr. httpd
process, it starts behaving again - consistently
(pseudo-consistently?)..., but now SIG{CHLD} is defined and eq ''. For some
reason, SIG{CHLD} defaults to undef, but I cannot set it to undef, or I get
a warning, and its value gets set to ''. Why does $SIG{CHLD}='' work, and
are there any potential side effects of this?

The CGI part of my "real" application is around 13500 lines, and I really
don't know where it is going wrong. I don't touch SIG{CHLD}. I must be
doing something that puts mod-perl in a state where it starts failing.
Should I be doing anything special for file handles? File locking problems
(I am *certain* there is only two flock instances in the code: a  perfectly
matched LOCK_EX/LOCK_UN pair)? You name it? I've tried to find these things
myself, but it looks to me as if everything is fine. And to inspect all the
code closely is just too much when I don't know what I'm looking for. Under
/proc I can see that the http process does not have a lot of open file
handles... (16 pr process - just like after a restart)

Any ideas why / where to start looking? I need to come up with a patch
soon, and I'd hate to have to disable mod-perl and go back to plain ol'

Especially, is there any interesting things to inspect once the mod-perl
process has started doing this? An apache restart *always* cures it, but
since it can take days for it to reappear, I'd like to make the most of the
debugging effort when its there. It seems to be sensitive to changes in
SIG{CHLD} but I don't know why or how.

I wasn't very sure what info to include, but I can send all the info you
need. It was difficult for me to tell what info this scenario requires.

Kind regards,

Peter Morch, CapMon

Output in the beginning of mod-perl.
Result: Result is something ,undef

Output under mod_perl after "a while".
Error: -1, No child processes, 10, Result is something , undef

(Note how the `echo Result is something` actually really did succeed.)

Output after having run with uncommented $SIG{CHLD} line from listing ONCE
in the past
Result: Result is something ,empty

Output under "unmod"-perl at any time
Result: Result is something ,undef

Versions, etc.
Running on SuSE Linux 7.2

lyta@pvm:~> rpm -qa | grep mod_perl
lyta@pvm:~> rpm -qa | grep apache
lyta@pvm:~> perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
    osname=linux, osvers=2.4.3, archname=i586-linux
    uname='linux subbotin 2.4.3 #1 tue may 8 21:54:34 gmt 2001 i686 unknown
    config_args='-ds -e -Dprefix=/usr -Di_db -Di_dbm -Di_ndbm -Di_gdbm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
    useperlio=undef d_sfio=undef uselargefiles=define
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
    cc='cc', optimize='-O2 -pipe', gccversion=2.95.3 20010315 (SuSE)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  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 May 11 2001 15:16:11

Information from TOP
  1:31pm  up 7 days, 23:33,  5 users,  load average: 0.06, 0.10, 0.09
2 processes: 2 sleeping, 0 running, 0 zombie, 0 stopped
CPU states:  4.2% user,  4.6% system,  0.0% nice,  3.9% idle
Mem:   254936K av,  239468K used,   15468K free,       0K shrd,    4304K
Swap:  385552K av,   15120K used,  370432K free                   63924K

22007 wwwrun     9   0 18804  18M 10596 S     0.0  7.3   0:12 httpd
22003 wwwrun     9   0 19104  18M 10612 S     0.0  7.4   0:15 httpd

View raw message