1 |
#include <stdlib.h> |
#include <stdlib.h> |
2 |
#include <stdio.h> |
#include <stdio.h> |
3 |
#include <process.h> /* for msvc _beginthreadex, _endthreadex */ |
#include <process.h> /* for msvc _beginthreadex, _endthreadex */ |
4 |
|
#include <signal.h> |
5 |
#include <windows.h> |
#include <windows.h> |
6 |
|
|
7 |
#include "sub_proc.h" |
#include "sub_proc.h" |
523 |
|
|
524 |
pproc->last_err = GetLastError(); |
pproc->last_err = GetLastError(); |
525 |
pproc->lerrno = E_FORK; |
pproc->lerrno = E_FORK; |
526 |
fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n", exec_path, command_line); |
fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n", |
527 |
|
exec_path ? exec_path : "NULL", command_line); |
528 |
if (envblk) free(envblk); |
if (envblk) free(envblk); |
529 |
free( command_line ); |
free( command_line ); |
530 |
return(-1); |
return(-1); |
764 |
|
|
765 |
} else if (ready_hand == childhand) { |
} else if (ready_hand == childhand) { |
766 |
|
|
767 |
GetExitCodeResult = GetExitCodeProcess(childhand, (DWORD*)&pproc->exit_code); |
DWORD ierr; |
768 |
|
GetExitCodeResult = GetExitCodeProcess(childhand, &ierr); |
769 |
|
if (ierr == CONTROL_C_EXIT) { |
770 |
|
pproc->signal = SIGINT; |
771 |
|
} else { |
772 |
|
pproc->exit_code = ierr; |
773 |
|
} |
774 |
if (GetExitCodeResult == FALSE) { |
if (GetExitCodeResult == FALSE) { |
775 |
pproc->last_err = GetLastError(); |
pproc->last_err = GetLastError(); |
776 |
pproc->lerrno = E_SCALL; |
pproc->lerrno = E_SCALL; |
819 |
HANDLE childhand; |
HANDLE childhand; |
820 |
DWORD wait_return; |
DWORD wait_return; |
821 |
BOOL GetExitCodeResult; |
BOOL GetExitCodeResult; |
822 |
|
DWORD ierr; |
823 |
|
|
824 |
if (proc == NULL) |
if (proc == NULL) |
825 |
pproc = process_wait_for_any_private(); |
pproc = process_wait_for_any_private(); |
863 |
goto done2; |
goto done2; |
864 |
} |
} |
865 |
|
|
866 |
GetExitCodeResult = GetExitCodeProcess(childhand, (DWORD*)&pproc->exit_code); |
GetExitCodeResult = GetExitCodeProcess(childhand, &ierr); |
867 |
|
if (ierr == CONTROL_C_EXIT) { |
868 |
|
pproc->signal = SIGINT; |
869 |
|
} else { |
870 |
|
pproc->exit_code = ierr; |
871 |
|
} |
872 |
if (GetExitCodeResult == FALSE) { |
if (GetExitCodeResult == FALSE) { |
873 |
pproc->last_err = GetLastError(); |
pproc->last_err = GetLastError(); |
874 |
pproc->lerrno = E_SCALL; |
pproc->lerrno = E_SCALL; |
1177 |
TRUE, |
TRUE, |
1178 |
DUPLICATE_SAME_ACCESS) == FALSE) { |
DUPLICATE_SAME_ACCESS) == FALSE) { |
1179 |
fprintf(stderr, |
fprintf(stderr, |
1180 |
"process_easy: DuplicateHandle(In) failed (e=%d)\n", |
"process_easy: DuplicateHandle(In) failed (e=%ld)\n", |
1181 |
GetLastError()); |
GetLastError()); |
1182 |
return INVALID_HANDLE_VALUE; |
return INVALID_HANDLE_VALUE; |
1183 |
} |
} |
1189 |
TRUE, |
TRUE, |
1190 |
DUPLICATE_SAME_ACCESS) == FALSE) { |
DUPLICATE_SAME_ACCESS) == FALSE) { |
1191 |
fprintf(stderr, |
fprintf(stderr, |
1192 |
"process_easy: DuplicateHandle(Out) failed (e=%d)\n", |
"process_easy: DuplicateHandle(Out) failed (e=%ld)\n", |
1193 |
GetLastError()); |
GetLastError()); |
1194 |
return INVALID_HANDLE_VALUE; |
return INVALID_HANDLE_VALUE; |
1195 |
} |
} |
1201 |
TRUE, |
TRUE, |
1202 |
DUPLICATE_SAME_ACCESS) == FALSE) { |
DUPLICATE_SAME_ACCESS) == FALSE) { |
1203 |
fprintf(stderr, |
fprintf(stderr, |
1204 |
"process_easy: DuplicateHandle(Err) failed (e=%d)\n", |
"process_easy: DuplicateHandle(Err) failed (e=%ld)\n", |
1205 |
GetLastError()); |
GetLastError()); |
1206 |
return INVALID_HANDLE_VALUE; |
return INVALID_HANDLE_VALUE; |
1207 |
} |
} |