diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-12-01 22:53:30 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-12-01 23:21:44 +0900 |
| commit | b89bc8a6cb3b93997647ceefc5b17bf05f20a0d0 (patch) | |
| tree | 0a84baa615a1b03e7e4d3f371394399e0b9126bb /src/DownloadEngineFactory.cc | |
| parent | ce3b3fc88e64722b462c708b2c5ddefa942c50b1 (diff) | |
Added --stop-with-process=PID option.
This feature stops application when process PID is not running. This
is useful if aria2 process is forked from a parent process. The parent
process can fork aria2 with its own pid and when parent process exits
for some reason, aria2 can detect it and shutdown itself.
The code which detects whether or not given process PID is running is
contributed by Emmanuel Engelhart.
Diffstat (limited to 'src/DownloadEngineFactory.cc')
| -rw-r--r-- | src/DownloadEngineFactory.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index 5bd8d53d..9fd1db42 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -52,6 +52,7 @@ #include "AutoSaveCommand.h" #include "HaveEraseCommand.h" #include "TimedHaltCommand.h" +#include "WatchProcessCommand.h" #include "DownloadResult.h" #include "ServerStatMan.h" #include "a2io.h" @@ -163,6 +164,10 @@ DownloadEngineFactory::newDownloadEngine stopSec)); } } + if(op->defined(PREF_STOP_WITH_PROCESS)) { + unsigned int pid = op->getAsInt(PREF_STOP_WITH_PROCESS); + e->addRoutineCommand(new WatchProcessCommand(e->newCUID(), e.get(), pid)); + } if(op->getAsBool(PREF_ENABLE_RPC)) { bool ok = false; static int families[] = { AF_INET, AF_INET6 }; |
