[Speedycgi-users] File descriptors > 2 and SpeedyCGI
Brought to you by:
samh
|
From: Japheth C. <cl...@ix...> - 2004-01-07 03:19:31
|
Hello everyone... I've run into a problem where I'm trying to use SpeedyCGI to replace a script that needs to access some previously-opened file descriptors that are grater than 3 to read and write from. (It's something that's going to get inserted into a qmail server stream, if anyone cares.) It looks like SpeedyCGI though, uses the file descriptors -- especially those starting around 15 or so -- for communicating environment or other things to the backend processes (is that right? was trying to examine the code...) and in the process apparently closes any descriptors above #2. Is there an easy way to get around this? Or if I wanted to patch this, where might I start poking around? Why is this needed? Well, qmail uses DJB''s ucspi protocol at http://cr.yp.to/proto/ucspi.txt -- and at various points it communicates to other programs over decriptors #6 and #7. If you have tcpclient installed, a test case is included below. Called properly, it connects to localhost port 25 and issues a QUIT command after the SMTP ok message. It works under standard Perl but under SpeedyCGI I get a "Bad file descriptor" at line 16. Any help would be much appreciated =) Sincerely, Japheth Cleaver cl...@ro... ---- BEGIN SAMPLE CODE ---- #!/usr/bin/perl #!/usr/bin/speedy # This script attempts to speak SMTP, reading from from file descriptor # 6 and writing to file descriptor 7; should be called using DJB's # "tcpclient" program like so: # # [root@testmail root]# tcpclient 127.0.0.1 25 /root/test.pl # # Works fine under standard perl, but complains when called # persistently. # # cl...@ro... # open (INCOMING, '<&=6') or die "Can't read in! $!"; select INCOMING; $|=1; open (OUTGOING, '>&=7') or die "Can't speak out! $!"; select OUTGOING; $|=1; select STDOUT; while (<INCOMING>) { print STDERR ">> Received: ", $_; if (m/^220/) { print OUTGOING "QUIT\n"; print STDERR "(sending QUIT)\n"; }; }; close OUTGOING; close INCOMING; __END__ |