| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 // The following is the C version of code from base/process_utils_linux.cc. | 5 // The following is the C version of code from base/process_utils_linux.cc. |
| 6 // We shouldn't link against C++ code in a setuid binary. | 6 // We shouldn't link against C++ code in a setuid binary. |
| 7 | 7 |
| 8 #include "process_util.h" | 8 #include "process_util.h" |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 if (getuid() != statbuf.st_uid) | 31 if (getuid() != statbuf.st_uid) |
| 32 return false; | 32 return false; |
| 33 | 33 |
| 34 strcat(oom_adj, "/oom_adj"); | 34 strcat(oom_adj, "/oom_adj"); |
| 35 int fd = open(oom_adj, O_WRONLY); | 35 int fd = open(oom_adj, O_WRONLY); |
| 36 if (fd < 0) | 36 if (fd < 0) |
| 37 return false; | 37 return false; |
| 38 | 38 |
| 39 char buf[3]; // 0 <= |score| <= 15; | 39 char buf[3]; // 0 <= |score| <= 15; |
| 40 snprintf(buf, sizeof(buf), "%d", score); | 40 snprintf(buf, sizeof(buf), "%d", score); |
| 41 size_t len = strlen(buf); | 41 ssize_t len = strlen(buf); |
| 42 | 42 |
| 43 ssize_t bytes_written = write(fd, buf, len); | 43 ssize_t bytes_written = write(fd, buf, len); |
| 44 close(fd); | 44 close(fd); |
| 45 return (bytes_written == len); | 45 return (bytes_written == len); |
| 46 } | 46 } |
| OLD | NEW |