Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Unified Diff: child_job.cc

Issue 661224: Stop infinite restarting (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « child_job.h ('k') | child_job_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: child_job.cc
diff --git a/child_job.cc b/child_job.cc
index 42b55d1ba804275d35aac06ac2d6f94b75fb70ae..c5ab56a6bf802d41b85c4389085c660e7d3d0879 100644
--- a/child_job.cc
+++ b/child_job.cc
@@ -11,6 +11,7 @@
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
+#include <time.h>
#include <unistd.h>
#include <base/basictypes.h>
@@ -36,7 +37,8 @@ SetUidExecJob::SetUidExecJob(const CommandLine* command_line,
num_args_passed_in_(0),
desired_uid_(0),
include_login_flag_(add_flag),
- set_uid_(false) {
+ set_uid_(false),
+ last_start_(0) {
PopulateArgv(command_line);
}
@@ -111,6 +113,14 @@ bool SetUidExecJob::ShouldRun() {
return !checker_->exists();
}
+bool SetUidExecJob::ShouldStop() {
+ return (time(NULL) - last_start_ < 1);
DaveMoore 2010/02/27 00:56:17 Nit: could you make this a constant?
+}
+
+void SetUidExecJob::RecordTime() {
+ time(&last_start_);
+}
+
void SetUidExecJob::Run() {
UseLoginManagerFlagIfNeeded();
// We try to set our UID/GID to the desired UID, and then exec
« no previous file with comments | « child_job.h ('k') | child_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698