http://www.berklix.com/~jhs/src/bsd/fixes/FreeBSD/ports/gen/www/httrack/files/patch-jc.httrack-3.43.12.REL=8.2-RELEASE.cust_rel by jhs@@berklix.com For all of: - httrack-3.43.12 in FreeBSD-8.2 release ports/ - httrack-3.45.3 in FreeBSD current ports/ @ Sun Apr 22 14:33:20 CEST 2012 *** src/htscoremain.c.orig Thu Mar 22 20:07:20 2012 --- src/htscoremain.c Sun Apr 22 18:36:16 2012 *************** *** 971,976 **** --- 971,978 ---- // case 'X': opt->delete_old=1; if (*(com+1)=='0') { opt->delete_old=0; com++; } break; // + case 'y': opt->background_on_suspend=1; break; + // case 'b': sscanf(com+1,"%d",&opt->accept_cookie); while(isdigit((unsigned char)*(com+1))) com++; break; // case 'N': *** src/httrack.c.orig Thu Mar 22 20:07:20 2012 --- src/httrack.c Sun Apr 22 19:14:54 2012 *************** *** 163,168 **** --- 163,188 ---- static httrackp *global_opt = NULL; static void signal_handlers(void); + static void signal_handlers2(void); + + int background_on_suspend = 0 ; + /* + * Leave at 0, if you want Normal Unix behaviour + * of Suspend signal suspending a process. + * Set to 1, if you want the old httrack behaviour + * (at 3.45.3) + * of dropping process into background. ******************* + * Dropping to background may pain, eg jhs@@berklix.com noted: + * Httrack sucked the performance out of my (jhs@@berklix.com) + * DSL coms link even with httrack rate limiting enabled. + * Browsers timed out, I could not temporarily suspend long + * runnning httrack processes, to let browsers recover & + * humans to get some urgent work done. (There were also + * sometimes eg 2 httracks, 1 on each of 2 internal hosts, + * both sucking different parts of the net, through 1 common + * busy gateway, & although both rate limited, browsers still + * timed out. + */ int main(int argc, char **argv) { int ret = 0; *** src/httrack.c.orig Thu Mar 22 20:07:20 2012 --- src/httrack.c Sun Apr 22 19:14:54 2012 *************** *** 187,192 **** --- 207,213 ---- #endif signal_handlers(); + // signal_handlers2(); // This must move to somewhere later after parameters get parsed. hts_init(); opt = global_opt = hts_create_opt(); *** src/httrack.c.orig Thu Mar 22 20:07:20 2012 --- src/httrack.c Sun Apr 22 19:14:54 2012 *************** *** 214,219 **** --- 235,242 ---- CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, NULL); + signal_handlers2(); // JJLATER guess around here maybe good ? + ret = hts_main2(argc, argv, opt); if (ret) { fprintf(stderr, "* %s\n", hts_errmsg(opt)); *** src/httrack.c.orig Thu Mar 22 20:07:20 2012 --- src/httrack.c Sun Apr 22 19:14:54 2012 *************** *** 706,711 **** --- 729,735 ---- #else static void sig_doback(int blind); static void sig_back( int code ) { // ignorer et mettre en backing + // Background the process. signal(code,sig_ignore); sig_doback(0); } *** src/httrack.c.orig Thu Mar 22 20:07:20 2012 --- src/httrack.c Sun Apr 22 19:14:54 2012 *************** *** 795,801 **** #if 0 /* BUG366763 */ signal( SIGHUP , sig_back ); // close window #endif ! signal( SIGTSTP , sig_back ); // ^Z signal( SIGTERM , sig_finish ); // kill #if 0 /* BUG366763 */ signal( SIGINT , sig_ask ); // ^C --- 819,825 ---- #if 0 /* BUG366763 */ signal( SIGHUP , sig_back ); // close window #endif ! // if (background_on_suspend) signal( SIGTSTP , sig_back ); // ^Z Moved to signal_handlers2() signal( SIGTERM , sig_finish ); // kill #if 0 /* BUG366763 */ signal( SIGINT , sig_ask ); // ^C *** src/httrack.c.orig Thu Mar 22 20:07:20 2012 --- src/httrack.c Sun Apr 22 19:14:54 2012 *************** *** 807,810 **** --- 831,841 ---- #endif } + static void signal_handlers2(void) { + #ifdef _WIN32 + #else + if (background_on_suspend) signal( SIGTSTP , sig_back ); // ^Z + #endif + } + // fin routines de détournement de SIGHUP & co