Discussione:
block STDIN
(troppo vecchio per rispondere)
Larry
2008-10-11 22:01:51 UTC
Permalink
#!/usr/bin/perl

use strict;
use warnings;
# use IO::Handle '_IONBF';
# use constant BUFSIZE => 1024 * 2;
use CGI;
my $q = new CGI();

$CGI::DISABLE_UPLOADS = 1;

print "content-type: text/plain\n\n";

__END__;

my $io = new IO::Handle;

if ( $io->fdopen(fileno(STDIN),"r") )
{
while($io->read(my $buf, BUFSIZE))
{

}
$io->close;
}

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
claudio 531 0.0 0.0 0 0 ? Z 19:13 0:00 [receiver.cgi]
<defunct>


Hi,

i have a script running on a web server (Apache) that accepts data
from STDIN and saves it:

#!/perl

use IO::Handle '_IONBF';
use constant BUFSIZE => 1024 * 2;

my $io = new IO::Handle;

if ( $io->fdopen(fileno(STDIN),"r") )
{
while($io->read($buf, BUFSIZE))
{
# ... save $buf ...
}
$io->close;
}

__END__;

I decided to check out if a user can upload to this script or else my
web server would screw up. So I put this on top of my script:

if ($ENV{"HTTP_USER_PASS"} ne 'mypassword')
{
close STDIN;
exit;
}

then I sent a couple of MBs of data thru http without the USER_PASS
header, i was struck by my finding out the script sort of died but I was
still sending raw data to the script...I though close STDIN would drop
the connection, too bad it didn't.

then, i tried to send the data to the following CGI script:

#!/usr/bin/perl

use strict;
use warnings;
use CGI;
my $q = new CGI();

$CGI::DISABLE_UPLOADS = 1;

print "content-type: text/plain\n\n";

__END__;

it just keeps on accetping the data...so i tried ps -ux on the web server

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
claudio 531 0.0 0.0 0 0 ? Z 19:13 0:00 [receiver.cgi]
<defunct>

what is <defunct>?? i tried to kill it, yet i didnt get...thats so
strange!
Andrea D'Amore
2008-10-12 05:38:42 UTC
Permalink
Post by Larry
what is <defunct>?? i tried to kill it, yet i didnt get...thats so
strange!
Hi,
the "it." part of the group name stands for "italian" rather than
"information technology".
Anyway this is a so low traffic group that your message isn't hurting at
all.

Back to your problem I think what's still getting the connection open is
apache itself.

The uploading client is not directly connected to the perl script but to
the apache server so you should investigate apache behaviour itself and,
as specific topic, your CGI launcher behaviour (there are different
launchers for CGIs).

The defunct process is (or should be) a process lying in process table
waiting for its parent to properly close it, you could try a SIGKILL
termination.

Loading...