CGI from Apache, broken pipe

半腔热情 提交于 2019-12-13 04:28:07

问题


What does happen with Apache (or Nginx) running a CGI script when the client (I mean a browser or a TCP gateway) disconnects in the middle?

  1. Does Apache/Nginx log an error? (If yes, which one and where?)

  2. Is the CGI script sent SIGPIPE to?


回答1:


There is no SIGPIPE when Apache CGI script is interrupted.

Tested with the following code:

#!/usr/bin/perl

use strict;
use warnings;

$| = 1;

#$SIG{PIPE} = "IGNORE";
$SIG{PIPE} = sub {
  open my $f, '>', 'log.txt';
  print $f "PIPE: $ENV{SERVER_NAME}\n";
  close $f;
};

print "Content-Type: text/plain\n\n";

sleep 10;

print "OK";


来源:https://stackoverflow.com/questions/52236675/cgi-from-apache-broken-pipe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!