summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/htsalias.c2
-rw-r--r--src/htscoremain.c2
-rw-r--r--src/htslib.c1
-rw-r--r--src/htsopt.h2
-rw-r--r--src/httrack.c35
5 files changed, 40 insertions, 2 deletions
diff --git a/src/htsalias.c b/src/htsalias.c
index 1990258..d06936f 100644
--- a/src/htsalias.c
+++ b/src/htsalias.c
@@ -174,6 +174,8 @@ const char* hts_optalias[][4] = {
{"dos83","-L0","single",""},
{"iso9660","-L2","single",""},
{"disable-module","-%w","param1",""},
+ {"no-background-on-suspend","-y0","single",""},
+ {"background-on-suspend","-y","single",""},
/* */
/* DEPRECATED */
diff --git a/src/htscoremain.c b/src/htscoremain.c
index 5f9c8a7..e7d7ad0 100644
--- a/src/htscoremain.c
+++ b/src/htscoremain.c
@@ -967,6 +967,8 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp *opt) {
//
case 'X': opt->delete_old=1; if (*(com+1)=='0') { opt->delete_old=0; com++; } break;
//
+ case 'y': opt->background_on_suspend=1; if (*(com+1)=='0') { opt->background_on_suspend=0; com++; } break;
+ //
case 'b': sscanf(com+1,"%d",&opt->accept_cookie); while(isdigit((unsigned char)*(com+1))) com++; break;
//
case 'N':
diff --git a/src/htslib.c b/src/htslib.c
index 6515bd1..8db1273 100644
--- a/src/htslib.c
+++ b/src/htslib.c
@@ -5255,6 +5255,7 @@ HTSEXT_API httrackp *hts_create_opt(void) {
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)
diff --git a/src/htsopt.h b/src/htsopt.h
index 15df2b4..6990226 100644
--- a/src/htsopt.h
+++ b/src/htsopt.h
@@ -368,6 +368,8 @@ struct httrackp {
htslibhandles libHandles;
//
htsoptstate state; // state
+ //
+ int background_on_suspend; // Background process on suspend signal.
};
// stats for httrack
diff --git a/src/httrack.c b/src/httrack.c
index 1d25d69..52a92e7 100644
--- a/src/httrack.c
+++ b/src/httrack.c
@@ -31,7 +31,7 @@ Please visit our Website: http://www.httrack.com
/* ------------------------------------------------------------ */
/* File: htsshow.c console progress info */
-/* Only used on Linux version */
+/* Only used on Linux & FreeBSD versions */
/* Author: Xavier Roche */
/* ------------------------------------------------------------ */
@@ -163,6 +163,26 @@ static int use_show;
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;
@@ -187,6 +207,7 @@ int main(int argc, char **argv) {
#endif
signal_handlers();
+ // signal_handlers2(); // This must move to somewhere later after parameters get parsed.
hts_init();
opt = global_opt = hts_create_opt();
@@ -214,6 +235,8 @@ int main(int argc, char **argv) {
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));
@@ -706,6 +729,7 @@ static void sig_ask( int code ) { // demander
#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);
}
@@ -796,7 +820,7 @@ static void signal_handlers(void) {
#if 0 /* BUG366763 */
signal( SIGHUP , sig_back ); // close window
#endif
- signal( SIGTSTP , sig_back ); // ^Z
+ // if (background_on_suspend) signal( SIGTSTP , sig_back ); // ^Z Moved to signal_handlers2()
signal( SIGTERM , sig_finish ); // kill <process>
#if 0 /* BUG366763 */
signal( SIGINT , sig_ask ); // ^C
@@ -808,4 +832,11 @@ static void signal_handlers(void) {
#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