Split command into process and adb
The process API provides the system-specific implementation, the adb API uses it to expose adb commands.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
# define _DARWIN_C_SOURCE // for strdup(), strtok_r(), memset_pattern4()
|
||||
#endif
|
||||
|
||||
#include "command.h"
|
||||
#include "util/process.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "util/log.h"
|
||||
|
||||
bool
|
||||
cmd_search(const char *file) {
|
||||
search_executable(const char *file) {
|
||||
char *path = getenv("PATH");
|
||||
if (!path)
|
||||
return false;
|
||||
@@ -63,7 +63,7 @@ cmd_search(const char *file) {
|
||||
}
|
||||
|
||||
enum process_result
|
||||
cmd_execute(const char *const argv[], pid_t *pid) {
|
||||
process_execute(const char *const argv[], pid_t *pid) {
|
||||
int fd[2];
|
||||
|
||||
if (pipe(fd) == -1) {
|
||||
@@ -125,7 +125,7 @@ end:
|
||||
}
|
||||
|
||||
bool
|
||||
cmd_terminate(pid_t pid) {
|
||||
process_terminate(pid_t pid) {
|
||||
if (pid <= 0) {
|
||||
LOGC("Requested to kill %d, this is an error. Please report the bug.\n",
|
||||
(int) pid);
|
||||
@@ -135,7 +135,7 @@ cmd_terminate(pid_t pid) {
|
||||
}
|
||||
|
||||
bool
|
||||
cmd_simple_wait(pid_t pid, int *exit_code) {
|
||||
process_simple_wait(pid_t pid, int *exit_code) {
|
||||
int status;
|
||||
int code;
|
||||
if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status)) {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "command.h"
|
||||
#include "util/process.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -21,7 +21,7 @@ build_cmd(char *cmd, size_t len, const char *const argv[]) {
|
||||
}
|
||||
|
||||
enum process_result
|
||||
cmd_execute(const char *const argv[], HANDLE *handle) {
|
||||
process_execute(const char *const argv[], HANDLE *handle) {
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
memset(&si, 0, sizeof(si));
|
||||
@@ -55,12 +55,12 @@ cmd_execute(const char *const argv[], HANDLE *handle) {
|
||||
}
|
||||
|
||||
bool
|
||||
cmd_terminate(HANDLE handle) {
|
||||
process_terminate(HANDLE handle) {
|
||||
return TerminateProcess(handle, 1);
|
||||
}
|
||||
|
||||
bool
|
||||
cmd_simple_wait(HANDLE handle, DWORD *exit_code) {
|
||||
process_simple_wait(HANDLE handle, DWORD *exit_code) {
|
||||
DWORD code;
|
||||
if (WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0
|
||||
|| !GetExitCodeProcess(handle, &code)) {
|
||||
Reference in New Issue
Block a user