diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2012-05-01 16:25:50 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2012-05-01 16:25:50 +0000 |
commit | 4c7ec9bf95f823654bae8dac7edbed2615adb27e (patch) | |
tree | e45059be12207f4a2f6584776362747df1b3ef1b /src | |
parent | 8cd02da424dc7238c1ee39339699cc8a7f98ef22 (diff) |
Do not interpret ^C before mirror is finished, or after!
Diffstat (limited to 'src')
-rw-r--r-- | src/htscoremain.c | 2 | ||||
-rw-r--r-- | src/htsopt.h | 1 | ||||
-rw-r--r-- | src/httrack.c | 23 |
3 files changed, 15 insertions, 11 deletions
diff --git a/src/htscoremain.c b/src/htscoremain.c index 2213feb..5f9c8a7 100644 --- a/src/htscoremain.c +++ b/src/htscoremain.c @@ -2177,6 +2177,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp *opt) { // Lancement du miroir // ------------------------------------------------------------ + opt->state._hts_in_mirror = 1; if (httpmirror(url, opt)==0) { printf("Error during operation (see log file), site has not been successfully mirrored\n"); } else { @@ -2188,6 +2189,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp *opt) { printf("Done.\n"); } } + opt->state._hts_in_mirror = 0; // ------------------------------------------------------------ // diff --git a/src/htsopt.h b/src/htsopt.h index f0e9ea9..15df2b4 100644 --- a/src/htsopt.h +++ b/src/htsopt.h @@ -222,6 +222,7 @@ struct htsoptstate { int _hts_in_html_done; int _hts_in_html_poll; int _hts_setpause; + int _hts_in_mirror; char** _hts_addurl; int _hts_cancel; htsoptstatecancel *cancel; /* 3.41 */ diff --git a/src/httrack.c b/src/httrack.c index 3c99dc7..1d25d69 100644 --- a/src/httrack.c +++ b/src/httrack.c @@ -752,11 +752,9 @@ static void sig_doback(int blind) { // mettre en backing out = open("hts-nohup.out",O_CREAT|O_WRONLY,S_IRUSR|S_IWUSR); if (out == -1) out = open("/dev/null",O_WRONLY,S_IRUSR|S_IWUSR); - close(0); - close(1); - dup(out); - close(2); - dup(out); + dup2(out, 0); + dup2(out, 1); + dup2(out, 2); // switch (fork()) { case 0: @@ -765,7 +763,6 @@ static void sig_doback(int blind) { // mettre en backing fprintf(stderr,"Error: can not fork process\n"); break; default: // pere - usleep(100000); // pause 1/10s "A microsecond is .000001s" _exit(0); break; } @@ -773,11 +770,15 @@ static void sig_doback(int blind) { // mettre en backing #endif static void sig_leave( int code ) { - signal(code, sig_term); // quitter si encore - printf("\n** Finishing pending transfers.. press again ^C to quit.\n"); - if (global_opt != NULL) { - // ask for stop - global_opt->state.stop=1; + if (global_opt != NULL && global_opt->state._hts_in_mirror) { + signal(code, sig_term); // quitter si encore + printf("\n** Finishing pending transfers.. press again ^C to quit.\n"); + if (global_opt != NULL) { + // ask for stop + global_opt->state.stop=1; + } + } else { + sig_term(code); } } |