diff --git a/source/app.d b/source/app.d index 1d22f3b..c97fa92 100644 --- a/source/app.d +++ b/source/app.d @@ -17,6 +17,17 @@ import cache : Cache; pragma(lib, "curl"); +version(linux) +{ + import core.sys.posix.signal; + import core.stdc.stdio; + + extern(C) void signalHandler(int signal) nothrow @nogc + { + printf("Caught signal %d\n", signal); + } +} + void main(string[] args) { int itag = 18; @@ -27,6 +38,11 @@ void main(string[] args) bool noProgress; bool noCache; + version(linux) + { + signal(SIGPIPE, &signalHandler); + } + auto help = args.getopt( std.getopt.config.passThrough, std.getopt.config.caseSensitive, diff --git a/source/downloaders.d b/source/downloaders.d index 1853832..0d4ceb8 100644 --- a/source/downloaders.d +++ b/source/downloaders.d @@ -45,6 +45,9 @@ class RegularDownloader : Downloader http.set(CurlOption.referer, referer); http.set(CurlOption.followlocation, true); http.set(CurlOption.failonerror, true); + http.set(CurlOption.timeout, 60 * 3); + http.set(CurlOption.connecttimeout, 60 * 3); + http.set(CurlOption.nosignal, true); http.onReceiveHeader = (in char[] header) { logger.displayVerbose(header);