Update process status when calling `process:running`
This commit is contained in:
parent
8caccbf6f0
commit
d4b8155cbc
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
@ -67,9 +68,10 @@ typedef enum {
|
||||||
static bool poll_process(process_t* proc, int timeout) {
|
static bool poll_process(process_t* proc, int timeout) {
|
||||||
if (!proc->running)
|
if (!proc->running)
|
||||||
return false;
|
return false;
|
||||||
unsigned int ticks = SDL_GetTicks();
|
uint32_t ticks = SDL_GetTicks();
|
||||||
if (timeout == WAIT_DEADLINE)
|
if (timeout == WAIT_DEADLINE)
|
||||||
timeout = proc->deadline;
|
timeout = proc->deadline;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD exit_code = -1;
|
DWORD exit_code = -1;
|
||||||
|
@ -90,9 +92,8 @@ static bool poll_process(process_t* proc, int timeout) {
|
||||||
if (timeout)
|
if (timeout)
|
||||||
SDL_Delay(5);
|
SDL_Delay(5);
|
||||||
} while (timeout == WAIT_INFINITE || SDL_GetTicks() - ticks < timeout);
|
} while (timeout == WAIT_INFINITE || SDL_GetTicks() - ticks < timeout);
|
||||||
if (!proc->running)
|
|
||||||
return false;
|
return proc->running;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool signal_process(process_t* proc, signal_e sig) {
|
static bool signal_process(process_t* proc, signal_e sig) {
|
||||||
|
@ -434,7 +435,7 @@ static int f_gc(lua_State* L) {
|
||||||
|
|
||||||
static int f_running(lua_State* L) {
|
static int f_running(lua_State* L) {
|
||||||
process_t* self = (process_t*)luaL_checkudata(L, 1, API_TYPE_PROCESS);
|
process_t* self = (process_t*)luaL_checkudata(L, 1, API_TYPE_PROCESS);
|
||||||
lua_pushboolean(L, self->running);
|
lua_pushboolean(L, poll_process(self, WAIT_NONE));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue