http://www.berklix.com/~jhs/src/bsd/fixes/FreeBSD/ports/gen/www/httrack/files/ patch-jc.httrack-3.47.21.REL=9.2-RELEASE.cust_rel by jhs@@berklix.com No need to patch src/htscoremain.c case 'y' *** src/httrack.c.orig Wed Jun 19 20:23:35 2013 --- src/httrack.c Tue Jan 28 01:53:25 2014 *************** *** 197,208 **** --- 197,236 ---- static int use_show; static httrackp *global_opt = NULL; + 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. + */ + static void signal_handlers(void); + static void signal_restore_ctl_z(void); int main(int argc, char **argv) { int ret = 0; httrackp *opt; + // Change from Xaviers default On to Off !!! + // otherwise it defaults to both capture & background on ^Z, which + // is not consistent with Unix expectations, & a Pain when one wants + // to temporarily suspend an httrack that is sucking the net link + // dry & get some decent interactive net performance for a human for + // a while, before letting httrack resume hoging most of bandwidth + // again later. + #ifdef _WIN32 { WORD wVersionRequested; // requested version WinSock API *************** *** 250,255 **** --- 278,287 ---- CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, NULL); + signal_restore_ctl_z(); // This must be after parameters get parsed. + // (But I do not know this code to know + // if that's now.) + ret = hts_main2(argc, argv, opt); if (ret) { fprintf(stderr, "* %s\n", hts_errmsg(opt)); *************** *** 783,788 **** --- 815,821 ---- #else static void sig_doback(int blind); static void sig_back(int code) { // ignorer et mettre en backing + // Ignore and Background the process. if (global_opt != NULL && !global_opt->background_on_suspend) { signal(SIGTSTP, SIG_DFL); // ^Z printf("\nInterrupting the program.\n"); *************** *** 795,800 **** --- 828,839 ---- } } + static void signal_restore_ctl_z(void) { + #ifndef _WIN32 + if (background_on_suspend) signal( SIGTSTP , sig_back ); // ^Z + #endif + } + #if 0 static void sig_ask(int code) { // demander char s[256]; *************** *** 889,895 **** #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 --- 928,937 ---- #if 0 /* BUG366763 */ signal(SIGHUP, sig_back); // close window #endif ! // Original author has next line uncommented, ! // but that is Not Unix standard. ! // Principle of least suprise requires this Off by default. ! // signal(SIGTSTP, sig_back); // ^Z signal(SIGTERM, sig_finish); // kill #if 0 /* BUG366763 */ signal(SIGINT, sig_ask); // ^C *** src/htslib.c.orig Tue Jan 28 01:02:57 2014 --- src/htslib.c Tue Jan 28 01:03:15 2014 *************** *** 5541,5547 **** opt->makeindex = 1; // faire un index opt->kindex = 0; // index 'keyword' opt->delete_old = 1; // effacer anciens fichiers ! opt->background_on_suspend = 1; // Background the process if Control Z calls signal suspend. opt->makestat = 0; // pas de fichier de stats opt->maketrack = 0; // ni de tracking opt->timeout = 120; // timeout par défaut (2 minutes) --- 5541,5547 ---- opt->makeindex = 1; // faire un index opt->kindex = 0; // index 'keyword' opt->delete_old = 1; // effacer anciens fichiers ! opt->background_on_suspend = 0; // Background the process if Control Z calls signal suspend. opt->makestat = 0; // pas de fichier de stats opt->maketrack = 0; // ni de tracking opt->timeout = 120; // timeout par défaut (2 minutes)