mirror of
https://github.com/janet-lang/janet
synced 2024-06-26 07:03:16 +00:00
Apply formatting to windows changes.
This commit is contained in:
parent
b0c09153c2
commit
b0b137d7f0
|
@ -322,7 +322,7 @@ typedef struct {
|
||||||
int flags;
|
int flags;
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
HANDLE pHandle;
|
HANDLE pHandle;
|
||||||
HANDLE tHandle;
|
HANDLE tHandle;
|
||||||
#else
|
#else
|
||||||
int pid;
|
int pid;
|
||||||
#endif
|
#endif
|
||||||
|
@ -350,10 +350,10 @@ static Janet os_proc_wait_impl(JanetProc *proc) {
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
WaitForSingleObject(proc->pHandle, INFINITE);
|
WaitForSingleObject(proc->pHandle, INFINITE);
|
||||||
GetExitCodeProcess(proc->pHandle, &status);
|
GetExitCodeProcess(proc->pHandle, &status);
|
||||||
if (!(proc->flags & JANET_PROC_CLOSED)) {
|
if (!(proc->flags & JANET_PROC_CLOSED)) {
|
||||||
proc->flags |= JANET_PROC_CLOSED;
|
proc->flags |= JANET_PROC_CLOSED;
|
||||||
CloseHandle(proc->pHandle);
|
CloseHandle(proc->pHandle);
|
||||||
CloseHandle(proc->tHandle);
|
CloseHandle(proc->tHandle);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
waitpid(proc->pid, &status, 0);
|
waitpid(proc->pid, &status, 0);
|
||||||
|
@ -376,8 +376,8 @@ static Janet os_proc_kill(int32_t argc, Janet *argv) {
|
||||||
janet_panicf("cannot close process handle that is already closed");
|
janet_panicf("cannot close process handle that is already closed");
|
||||||
}
|
}
|
||||||
proc->flags |= JANET_PROC_CLOSED;
|
proc->flags |= JANET_PROC_CLOSED;
|
||||||
CloseHandle(proc->pHandle);
|
CloseHandle(proc->pHandle);
|
||||||
CloseHandle(proc->tHandle);
|
CloseHandle(proc->tHandle);
|
||||||
#else
|
#else
|
||||||
int status = kill(proc->pid, SIGKILL);
|
int status = kill(proc->pid, SIGKILL);
|
||||||
if (status) {
|
if (status) {
|
||||||
|
@ -467,12 +467,12 @@ static Janet os_execute(int32_t argc, Janet *argv) {
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
|
|
||||||
HANDLE pHandle, tHandle;
|
HANDLE pHandle, tHandle;
|
||||||
PROCESS_INFORMATION processInfo;
|
PROCESS_INFORMATION processInfo;
|
||||||
STARTUPINFO startupInfo;
|
STARTUPINFO startupInfo;
|
||||||
memset(&processInfo, 0, sizeof(processInfo));
|
memset(&processInfo, 0, sizeof(processInfo));
|
||||||
memset(&startupInfo, 0, sizeof(startupInfo));
|
memset(&startupInfo, 0, sizeof(startupInfo));
|
||||||
startupInfo.cb = sizeof(startupInfo);
|
startupInfo.cb = sizeof(startupInfo);
|
||||||
startupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
startupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
|
|
||||||
JanetBuffer *buf = os_exec_escape(exargs);
|
JanetBuffer *buf = os_exec_escape(exargs);
|
||||||
if (buf->count > 8191) {
|
if (buf->count > 8191) {
|
||||||
|
@ -480,42 +480,42 @@ static Janet os_execute(int32_t argc, Janet *argv) {
|
||||||
}
|
}
|
||||||
const char *path = (const char *) janet_unwrap_string(exargs.items[0]);
|
const char *path = (const char *) janet_unwrap_string(exargs.items[0]);
|
||||||
|
|
||||||
/* Do IO redirection */
|
/* Do IO redirection */
|
||||||
startupInfo.hStdInput = (HANDLE) _get_osfhandle((new_in == NULL) ? 0 : _fileno(new_in->file));
|
startupInfo.hStdInput = (HANDLE) _get_osfhandle((new_in == NULL) ? 0 : _fileno(new_in->file));
|
||||||
startupInfo.hStdOutput = (HANDLE) _get_osfhandle((new_out == NULL) ? 1 : _fileno(new_out->file));
|
startupInfo.hStdOutput = (HANDLE) _get_osfhandle((new_out == NULL) ? 1 : _fileno(new_out->file));
|
||||||
startupInfo.hStdError = (HANDLE) _get_osfhandle((new_err == NULL) ? 2 : _fileno(new_err->file));
|
startupInfo.hStdError = (HANDLE) _get_osfhandle((new_err == NULL) ? 2 : _fileno(new_err->file));
|
||||||
|
|
||||||
/* Use _spawn family of functions. */
|
/* Use _spawn family of functions. */
|
||||||
/* Windows docs say do this before any spawns. */
|
/* Windows docs say do this before any spawns. */
|
||||||
_flushall();
|
_flushall();
|
||||||
|
|
||||||
/* TODO - redirection, :p flag */
|
/* TODO - redirection, :p flag */
|
||||||
if(!CreateProcess(janet_flag_at(flags, 1) ? NULL : path, /* NULL? */
|
if (!CreateProcess(janet_flag_at(flags, 1) ? NULL : path, /* NULL? */
|
||||||
(char *) buf->data, /* Single CLI argument */
|
(char *) buf->data, /* Single CLI argument */
|
||||||
NULL, /* no proc inheritance */
|
NULL, /* no proc inheritance */
|
||||||
NULL, /* no thread inheritance */
|
NULL, /* no thread inheritance */
|
||||||
TRUE, /* handle inheritance */
|
TRUE, /* handle inheritance */
|
||||||
0, /* flags */
|
0, /* flags */
|
||||||
envp, /* pass in environment */
|
envp, /* pass in environment */
|
||||||
NULL, /* use parents starting directory */
|
NULL, /* use parents starting directory */
|
||||||
&startupInfo,
|
&startupInfo,
|
||||||
&processInfo)) {
|
&processInfo)) {
|
||||||
janet_panic("failed to create process");
|
janet_panic("failed to create process");
|
||||||
}
|
}
|
||||||
|
|
||||||
pHandle = processInfo.hProcess;
|
pHandle = processInfo.hProcess;
|
||||||
tHandle = processInfo.hThread;
|
tHandle = processInfo.hThread;
|
||||||
|
|
||||||
os_execute_cleanup(envp, NULL);
|
os_execute_cleanup(envp, NULL);
|
||||||
|
|
||||||
/* Wait and cleanup immedaitely */
|
/* Wait and cleanup immedaitely */
|
||||||
if (!is_async) {
|
if (!is_async) {
|
||||||
DWORD code;
|
DWORD code;
|
||||||
WaitForSingleObject(pHandle, INFINITE);
|
WaitForSingleObject(pHandle, INFINITE);
|
||||||
GetExitCodeProcess(pHandle, &code);
|
GetExitCodeProcess(pHandle, &code);
|
||||||
status = (int) code;
|
status = (int) code;
|
||||||
CloseHandle(pHandle);
|
CloseHandle(pHandle);
|
||||||
CloseHandle(tHandle);
|
CloseHandle(tHandle);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -591,10 +591,10 @@ static Janet os_execute(int32_t argc, Janet *argv) {
|
||||||
JanetProc *proc = janet_abstract(&ProcAT, sizeof(JanetProc));
|
JanetProc *proc = janet_abstract(&ProcAT, sizeof(JanetProc));
|
||||||
proc->return_code = -1;
|
proc->return_code = -1;
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
proc->pHandle = pHandle;
|
proc->pHandle = pHandle;
|
||||||
proc->tHandle = tHandle;
|
proc->tHandle = tHandle;
|
||||||
#else
|
#else
|
||||||
proc->pid = pid;
|
proc->pid = pid;
|
||||||
#endif
|
#endif
|
||||||
proc->in = new_in;
|
proc->in = new_in;
|
||||||
proc->out = new_out;
|
proc->out = new_out;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user