Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
review feedback fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Nov 2, 2011
1 parent 31f94db commit 15c4253
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/unix/dl.c
Expand Up @@ -26,8 +26,6 @@
#include <errno.h>


static const uv_err_t uv_ok_ = { UV_OK, 0 };

uv_err_t uv_dlopen(const char* filename, uv_lib_t* library) {
void* handle = dlopen(filename, RTLD_LAZY);
if (handle == NULL) {
Expand Down
3 changes: 3 additions & 0 deletions src/uv-common.c
Expand Up @@ -48,6 +48,9 @@ uv_buf_t uv_buf_init(char* base, size_t len) {
}


const uv_err_t uv_ok_ = { UV_OK, 0 };


const char* uv_err_name(uv_err_t err) {
switch (err.code) {
case UV_UNKNOWN: return "UNKNOWN";
Expand Down
2 changes: 2 additions & 0 deletions src/uv-common.h
Expand Up @@ -48,6 +48,8 @@ void uv_add_ares_handle(uv_loop_t* loop, uv_ares_task_t* handle);

int uv_ares_handles_empty(uv_loop_t* loop);

extern const uv_err_t uv_ok_;

uv_err_code uv_translate_sys_error(int sys_errno);
void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error);
void uv__set_sys_error(uv_loop_t* loop, int sys_error);
Expand Down
3 changes: 0 additions & 3 deletions src/win/error.c
Expand Up @@ -30,9 +30,6 @@
#include "internal.h"


const uv_err_t uv_ok_ = { UV_OK, ERROR_SUCCESS };


/*
* Display an error message and abort the event loop.
*/
Expand Down
5 changes: 0 additions & 5 deletions src/win/internal.h
Expand Up @@ -286,11 +286,6 @@ void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle);
int uv_parent_pid();


/*
* Error handling
*/
extern const uv_err_t uv_ok_;

void uv_fatal_error(const int errorno, const char* syscall);

uv_err_code uv_translate_sys_error(int sys_errno);
Expand Down
16 changes: 8 additions & 8 deletions src/win/process.c
Expand Up @@ -1062,22 +1062,23 @@ static uv_err_t uv__kill(HANDLE process_handle, int signum) {
if (signum == SIGTERM || signum == SIGKILL) {
/* Kill the process. On Windows, killed processes normally return 1. */
if (TerminateProcess(process_handle, 1)) {
return uv_ok_;
err = uv_ok_;
} else {
return uv__new_sys_error(GetLastError());
err = uv__new_sys_error(GetLastError());
}
} else if (signum == 0) {
/* Health check: is the process still alive? */
if (GetExitCodeProcess(process_handle, &status) &&
status == STILL_ACTIVE) {
return uv_ok_;
err = uv_ok_;
} else {
err.code = UV_EINVAL;
return err;
err = uv__new_sys_error(GetLastError());
}
} else {
err.code = UV_ENOSYS;
}

return uv_ok_;
return err;
}


Expand Down Expand Up @@ -1108,8 +1109,7 @@ uv_err_t uv_kill(int pid, int signum) {
PROCESS_QUERY_INFORMATION, FALSE, pid);

if (process_handle == INVALID_HANDLE_VALUE) {
err.code = UV_EINVAL;
return err;
return uv__new_sys_error(GetLastError());
}

err = uv__kill(process_handle, signum);
Expand Down
2 changes: 1 addition & 1 deletion test/test-spawn.c
Expand Up @@ -72,7 +72,7 @@ static void kill_cb(uv_process_t* process, int exit_status, int term_signal) {
* child process is still alive, not kill it.
*/
err = uv_kill(process->pid, 0);
ASSERT(err.code == UV_EINVAL);
ASSERT(err.code != UV_OK);
}


Expand Down

0 comments on commit 15c4253

Please sign in to comment.