diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-03-26 17:12:52 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-03-26 17:20:27 +0900 |
| commit | d64089632e82a2548752c7a6baaa68365a795a74 (patch) | |
| tree | 57fc7b85a8c1290975d58fa4761b04a7695bf7e3 /src/WatchProcessCommand.cc | |
| parent | c81b1321122e8509b55c94c0cbca0d8d6d319f0c (diff) | |
| parent | a7cd943a06b1a5ff4515b57060b84037f8d01f9f (diff) | |
Merge branch 'master' into random-webseeding
Diffstat (limited to 'src/WatchProcessCommand.cc')
| -rw-r--r-- | src/WatchProcessCommand.cc | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/WatchProcessCommand.cc b/src/WatchProcessCommand.cc index 6c58d59d..d5067cb5 100644 --- a/src/WatchProcessCommand.cc +++ b/src/WatchProcessCommand.cc @@ -65,21 +65,16 @@ namespace aria2 { -WatchProcessCommand::WatchProcessCommand -(cuid_t cuid, - DownloadEngine* e, - unsigned int pid, - bool forceHalt) - : TimeBasedCommand(cuid, e, 1_s, true), - pid_(pid), - forceHalt_(forceHalt) -{} - +WatchProcessCommand::WatchProcessCommand(cuid_t cuid, DownloadEngine* e, + unsigned int pid, bool forceHalt) + : TimeBasedCommand(cuid, e, 1_s, true), pid_(pid), forceHalt_(forceHalt) +{ +} void WatchProcessCommand::preProcess() { - if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() || - getDownloadEngine()->isHaltRequested()) { + if (getDownloadEngine()->getRequestGroupMan()->downloadFinished() || + getDownloadEngine()->isHaltRequested()) { enableExit(); } } @@ -102,10 +97,10 @@ void WatchProcessCommand::process() struct kinfo_proc kp; size_t len = sizeof(kp); - mib[0]=CTL_KERN; - mib[1]=KERN_PROC; - mib[2]=KERN_PROC_PID; - mib[3]=pid_; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = pid_; int ret = sysctl(mib, MIBSIZE, &kp, &len, nullptr, 0); if (ret == -1 || len <= 0) { @@ -116,13 +111,14 @@ void WatchProcessCommand::process() waiting = false; } #endif - if(!waiting) { - A2_LOG_INFO - (fmt("CUID#%" PRId64 " - Process %u is not running. Commencing shutdown.", - getCuid(), pid_)); - if(forceHalt_) { + if (!waiting) { + A2_LOG_INFO(fmt("CUID#%" PRId64 + " - Process %u is not running. Commencing shutdown.", + getCuid(), pid_)); + if (forceHalt_) { getDownloadEngine()->requestForceHalt(); - } else { + } + else { getDownloadEngine()->requestHalt(); } enableExit(); |
