| | @@ -1418,10 +1418,23 @@ |
| 1418 | 1418 | */ |
| 1419 | 1419 | void sigsegv_handler(int x){ |
| 1420 | 1420 | fossil_errorlog("Segfault"); |
| 1421 | 1421 | exit(1); |
| 1422 | 1422 | } |
| 1423 | + |
| 1424 | +/* |
| 1425 | +** Called if a server gets a SIGPIPE. This often happens when a client |
| 1426 | +** webbrowser opens a connection but never sends the HTTP request |
| 1427 | +*/ |
| 1428 | +void sigpipe_handler(int x){ |
| 1429 | +#ifndef _WIN32 |
| 1430 | + if( g.fAnyTrace ){ |
| 1431 | + fprintf(stderr, "-- sigpipe received by subprocess %d --\n", getpid()); |
| 1432 | + } |
| 1433 | +#endif |
| 1434 | + fossil_exit(1); |
| 1435 | +} |
| 1423 | 1436 | |
| 1424 | 1437 | /* |
| 1425 | 1438 | ** Preconditions: |
| 1426 | 1439 | ** |
| 1427 | 1440 | ** * Environment variables are set up according to the CGI standard. |
| | @@ -2664,12 +2677,18 @@ |
| 2664 | 2677 | signal(SIGALRM, sigalrm_handler); |
| 2665 | 2678 | alarm(atoi(zMaxLatency)); |
| 2666 | 2679 | } |
| 2667 | 2680 | g.httpIn = stdin; |
| 2668 | 2681 | g.httpOut = stdout; |
| 2669 | | - if( g.fHttpTrace || g.fSqlTrace ){ |
| 2670 | | - fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 2682 | + |
| 2683 | +#if !defined(_WIN32) |
| 2684 | + signal(SIGSEGV, sigsegv_handler); |
| 2685 | + signal(SIGPIPE, sigpipe_handler); |
| 2686 | +#endif |
| 2687 | + |
| 2688 | + if( g.fAnyTrace ){ |
| 2689 | + fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 2671 | 2690 | } |
| 2672 | 2691 | g.cgiOutput = 1; |
| 2673 | 2692 | find_server_repository(2, 0); |
| 2674 | 2693 | if( fossil_strcmp(g.zRepositoryName,"/")==0 ){ |
| 2675 | 2694 | allowRepoList = 1; |
| | @@ -2680,10 +2699,14 @@ |
| 2680 | 2699 | cgi_handle_scgi_request(); |
| 2681 | 2700 | }else{ |
| 2682 | 2701 | cgi_handle_http_request(0); |
| 2683 | 2702 | } |
| 2684 | 2703 | process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList); |
| 2704 | + if( g.fAnyTrace ){ |
| 2705 | + fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n", |
| 2706 | + getpid()); |
| 2707 | + } |
| 2685 | 2708 | #else |
| 2686 | 2709 | /* Win32 implementation */ |
| 2687 | 2710 | if( isUiCmd ){ |
| 2688 | 2711 | zBrowser = db_get("web-browser", "start"); |
| 2689 | 2712 | if( zIpAddr==0 ){ |
| 2690 | 2713 | |