OLD | NEW |
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 Loading... |
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 |
OLD | NEW |