From b89bc8a6cb3b93997647ceefc5b17bf05f20a0d0 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 1 Dec 2011 22:53:30 +0900 Subject: 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. --- src/DownloadEngineFactory.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/DownloadEngineFactory.cc') 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 }; -- cgit