Incorporate realtakase's suggestions.
This commit is contained in:
parent
f24ebf853d
commit
3773a812bd
|
@ -330,8 +330,9 @@ static int f_write(lua_State* L) {
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
if (!WriteFile(self->child_pipes[STDIN_FD][1], data, data_size, &dwWritten, NULL)) {
|
if (!WriteFile(self->child_pipes[STDIN_FD][1], data, data_size, &dwWritten, NULL)) {
|
||||||
|
int lastError = GetLastError();
|
||||||
signal_process(self, SIGNAL_TERM);
|
signal_process(self, SIGNAL_TERM);
|
||||||
return luaL_error(L, "error writing to process: %d", GetLastError());
|
return luaL_error(L, "error writing to process: %d", lastError);
|
||||||
}
|
}
|
||||||
length = dwWritten;
|
length = dwWritten;
|
||||||
#else
|
#else
|
||||||
|
@ -339,8 +340,9 @@ static int f_write(lua_State* L) {
|
||||||
if (length < 0 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
if (length < 0 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
||||||
length = 0;
|
length = 0;
|
||||||
else if (length < 0) {
|
else if (length < 0) {
|
||||||
|
const char* lastError = strerror(errno);
|
||||||
signal_process(self, SIGNAL_TERM);
|
signal_process(self, SIGNAL_TERM);
|
||||||
return luaL_error(L, "error writing to process: %s", strerror(errno));
|
return luaL_error(L, "error writing to process: %s", lastError);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lua_pushinteger(L, length);
|
lua_pushinteger(L, length);
|
||||||
|
|
Loading…
Reference in New Issue