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

Side by Side Diff: utils.cc

Issue 3053049: Nice automatic updates up to a point, then renice if necessary. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: better documentation Created 10 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils.h ('k') | utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/utils.h" 5 #include "update_engine/utils.h"
6 6
7 #include <sys/mount.h> 7 #include <sys/mount.h>
8 #include <sys/resource.h>
8 #include <sys/stat.h> 9 #include <sys/stat.h>
9 #include <sys/types.h> 10 #include <sys/types.h>
10 #include <dirent.h> 11 #include <dirent.h>
11 #include <errno.h> 12 #include <errno.h>
12 #include <fcntl.h> 13 #include <fcntl.h>
13 #include <stdio.h> 14 #include <stdio.h>
14 #include <stdlib.h> 15 #include <stdlib.h>
15 #include <string.h> 16 #include <string.h>
16 #include <unistd.h> 17 #include <unistd.h>
17 18
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 vector<string> command; 438 vector<string> command;
438 command.push_back("/sbin/shutdown"); 439 command.push_back("/sbin/shutdown");
439 command.push_back("-r"); 440 command.push_back("-r");
440 command.push_back("now"); 441 command.push_back("now");
441 int rc = 0; 442 int rc = 0;
442 Subprocess::SynchronousExec(command, &rc); 443 Subprocess::SynchronousExec(command, &rc);
443 TEST_AND_RETURN_FALSE(rc == 0); 444 TEST_AND_RETURN_FALSE(rc == 0);
444 return true; 445 return true;
445 } 446 }
446 447
448 bool SetProcessPriority(ProcessPriority priority) {
449 int prio = static_cast<int>(priority);
450 LOG(INFO) << "Setting process priority to " << prio;
451 TEST_AND_RETURN_FALSE(setpriority(PRIO_PROCESS, 0, prio) == 0);
452 return true;
453 }
454
455 int ComparePriorities(ProcessPriority priority_lhs,
456 ProcessPriority priority_rhs) {
457 return static_cast<int>(priority_rhs) - static_cast<int>(priority_lhs);
458 }
459
447 const char* const kStatefulPartition = "/mnt/stateful_partition"; 460 const char* const kStatefulPartition = "/mnt/stateful_partition";
448 461
449 } // namespace utils 462 } // namespace utils
450 463
451 } // namespace chromeos_update_engine 464 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « utils.h ('k') | utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698