apache_registry_spawning_zombie_shells

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: Apache::Registry spawning zombie shells?
From: martin langhoff <martin@scim.net>
Date: Tue, 22 Aug 2000 12:29:37 -0300

hi list,

	while doing a silly thing (building a set of HTML files with info from
a DB file), I found that while the apache server was being crawled by
lwp-rget, a lots of zombie shells were being spawned and killed. 

	top was telling me that there were quite a few processes like:

 6766 nobody     2   0     0    0     0 Z       0  0.3  0.0   0:00 sh
<defunct>

(I was looking at top because I was happy thinking how mod_perl was
speeding it all up)

	so I checked and rechecked my code, 2 *very* silly cgi scripts hacked
in a hurry, that I renamed from .cgi to .pl so the crawling finished
faster. the scripts are at the bottom, but I don't think you'll find
much there. 

	needless to say, when run under mod_cgi, no sh is ever spawned, and
when the crawling finished no more spawning took place (3 of the zombie
shells remained, though). So it's definitely something with mod_perl and
Apache::Registry. Maybe the DB_File module has something blame? Don't
really know.

	these shells are not attached to any console, and they are sh shells,
while I use bash. queer. If it weren't because the server is
*disconnected* from the 'net I'd think the box was 'rooted'.

	I've even got to catch the actuall call to sh from ps:

sh -c /bin/csh -cf 'set nonomatch; glob /table' 2>/de

	what can that mean? I'm off to search ... 


martin

	system specs and scripts : 'Apache/1.3.12 (Unix) mod_perl/1.24'
--------------------------------------------------------------
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.5-22smp, archname=i386-linux
    uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2
09:11:51 ed
t 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux
(egcs-1.1.2
release)
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    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 -lposix -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):
  Built under linux
  Compiled at Aug 30 1999 23:09:51
  @INC:
    /usr/lib/perl5/5.00503/i386-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i386-linux
    /usr/lib/perl5/site_perl/5.005

	
--------------------------------------------------------------------
script letra.pl:
-------------------------------------------------------------------
#!/usr/bin/perl -w


use strict;
use DB_File;


use CGI;
use URI::Escape;

my $cgi = new CGI;
print $cgi->header();
my $letra = $cgi->param('letra');
my %db;

my $records = 0;

tie (%db, "DB_File", 'voluntarios.db') or die $!; 

print '<html><head><link rel="stylesheet"
href="fedefa.css"></head><body>';
print '<table width="600" border="1" bordercolor="#666666"
align="center">';

foreach my $key (sort { lc($a) cmp lc($b) } keys %db){
	if ($key =~ /^$letra/io){
		$records++;		
		print '<tr>
				<td width="21" bgcolor="#FFDBAD">
					<img src="lib/flecha.gif" width="21" height="20">
				</td>
				<td bgcolor="#0078B3" width="550">
					<b>';
		print $cgi->a( {href=>'record.pl?record=' . uri_escape($key)} ,
qq{<font color="#FFFFFF" face="Arial, Helvetica, sans-serif"
size="2">$key</font>});
		print '</font></b></td></tr>';
	}
};
unless ($records){
	$letra = uc $letra;
	print '<tr>
					<td width="21" bgcolor="#FFDBAD">
						<img src="/fedefa/lib/flecha.gif" width="21" height="20">
					</td>
					<td bgcolor="#0078B3" width="550">
						<b>';
			print qq{<font color="#FFFFFF" face="Arial, Helvetica, sans-serif"
size="2">No hay registros con la letra $letra</font>};
		print '</font></b></td></tr>';
}
print '</table>';
	
	
print '</body></html>';
  ----------------------------------------------------------------------
script record.pl
 ----------------------------------------------------------------------
#!/usr/bin/perl -w


use strict;
use DB_File;


use CGI;
use URI::Escape;

my $cgi = new CGI;
print $cgi->header();
my $record = $cgi->param('record');
my %db;
tie (%db, "DB_File", 'voluntarios.db') or die $!; 

print '<html><head><link rel="stylesheet"
href="fedefa.css"></head><body>';
print qq{<table width="350" border="1" bordercolor="#333333"
align="center">
			<tr>
				<td width="21" bgcolor="#FFDBAD"><img src="lib/flecha.gif"
width="21" height="20"></td>
				<td bgcolor="#0078B3"><font color="#FFFFFF"><b><font size="2"
face="Arial, Helvetica, sans-serif">&nbsp;&nbsp; $record
</font></b></font></td>
			  </tr>
};
		
		print '<tr><td>&nbsp;</td><td valign="top" bgcolor="#CCCCCC">';
		
		# elimino la 1er l

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu