| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "tools/android/common/daemon.h" | 5 #include "tools/android/common/daemon.h" |
| 6 | 6 |
| 7 #include <errno.h> |
| 7 #include <signal.h> | 8 #include <signal.h> |
| 8 #include <stdio.h> | 9 #include <stdio.h> |
| 9 #include <sys/types.h> | 10 #include <sys/types.h> |
| 10 #include <unistd.h> | 11 #include <unistd.h> |
| 11 | 12 |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/posix/eintr_wrapper.h" | |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const char kNoSpawnDaemon[] = "D"; | 18 const char kNoSpawnDaemon[] = "D"; |
| 19 | 19 |
| 20 int g_exit_status = 0; | 20 int g_exit_status = 0; |
| 21 | 21 |
| 22 void Exit(int unused) { | 22 void Exit(int unused) { |
| 23 _exit(g_exit_status); | 23 _exit(g_exit_status); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void CloseFileDescriptor(int fd) { | 26 void CloseFileDescriptor(int fd) { |
| 27 int old_errno = errno; | 27 int old_errno = errno; |
| 28 (void) HANDLE_EINTR(close(fd)); | 28 close(fd); |
| 29 errno = old_errno; | 29 errno = old_errno; |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 namespace tools { | 34 namespace tools { |
| 35 | 35 |
| 36 bool HasHelpSwitch(const CommandLine& command_line) { | 36 bool HasHelpSwitch(const CommandLine& command_line) { |
| 37 return command_line.HasSwitch("h") || command_line.HasSwitch("help"); | 37 return command_line.HasSwitch("h") || command_line.HasSwitch("help"); |
| 38 } | 38 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 | 66 |
| 67 // Close the standard input and outputs, otherwise the process may block | 67 // Close the standard input and outputs, otherwise the process may block |
| 68 // adbd when the shell exits. | 68 // adbd when the shell exits. |
| 69 // Comment out these lines if you want to see outputs for debugging. | 69 // Comment out these lines if you want to see outputs for debugging. |
| 70 CloseFileDescriptor(0); | 70 CloseFileDescriptor(0); |
| 71 CloseFileDescriptor(1); | 71 CloseFileDescriptor(1); |
| 72 CloseFileDescriptor(2); | 72 CloseFileDescriptor(2); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace tools | 75 } // namespace tools |
| OLD | NEW |