Changeset 2843 for trunk/src/kmk/w32
- Timestamp:
- Aug 28, 2016, 5:31:02 PM (9 years ago)
- Location:
- trunk/src/kmk/w32
- Files:
-
- 2 added
- 1 deleted
- 2 edited
-
Makefile.kmk (deleted)
-
Makefile.kup (added)
-
include/sub_proc.h (modified) (2 diffs)
-
subproc/Makefile.kup (added)
-
subproc/sub_proc.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/w32/include/sub_proc.h
r2591 r2843 39 39 EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data, 40 40 int stdin_data_len)); 41 #ifndef KMK /* unused */ 41 42 EXTERN_DECL(long process_file_io, (HANDLE proc)); 43 #endif 42 44 EXTERN_DECL(void process_cleanup, (HANDLE proc)); 43 45 EXTERN_DECL(HANDLE process_wait_for_any, (VOID_DECL)); … … 46 48 EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal)); 47 49 EXTERN_DECL(int process_used_slots, (VOID_DECL)); 50 #ifdef KMK 51 EXTERN_DECL(int process_kmk_register_submit, (HANDLE hEvent, intptr_t clue)); 52 #endif 48 53 49 54 /* support routines */ -
trunk/src/kmk/w32/subproc/sub_proc.c
r2636 r2843 27 27 #include <signal.h> 28 28 #include <windows.h> 29 #ifdef KMK 30 # include <assert.h> 31 # include "make.h" 32 # include "kmkbuiltin.h" 33 #endif 34 29 35 30 36 #include "sub_proc.h" … … 34 40 35 41 static char *make_command_line(char *shell_name, char *exec_path, char **argv); 42 #ifndef KMK 36 43 extern char *xmalloc (unsigned int); 37 # ifdef KMK44 #else 38 45 extern void kmk_cache_exec_image(const char *); /* imagecache.c */ 39 46 #endif 40 47 41 48 typedef struct sub_process_t { 49 #ifdef KMK 50 enum { kRegular = 0, kSubmit, kSubProcFreed } enmType; 51 intptr_t clue; 52 #endif 42 53 intptr_t sv_stdin[2]; 43 54 intptr_t sv_stdout[2]; … … 64 75 static int fake_exits_pending = 0; 65 76 77 #ifndef KMK /* Inefficient! */ 66 78 /* 67 79 * When a process has been waited for, adjust the wait state … … 88 100 } 89 101 } 102 #endif /* !KMK */ 90 103 91 104 /* … … 112 125 /* wait for someone to exit */ 113 126 if (!fake_exits_pending) { 127 #ifdef KMK 128 l_wait_again: 129 #endif 114 130 retval = WaitForMultipleObjects(proc_index, handles, FALSE, INFINITE); 115 131 which = retval - WAIT_OBJECT_0; … … 123 139 if (retval != WAIT_FAILED) { 124 140 sub_process* pproc = proc_array[which]; 141 #ifdef KMK 142 if (pproc->enmType == kSubmit) { 143 /* Try get the result from kSubmit.c. This may not succeed if the whole 144 result hasn't arrived yet, in which we just restart the wait. */ 145 if (kSubmitSubProcGetResult(pproc->clue, &pproc->exit_code, &pproc->signal) != 0) { 146 goto l_wait_again; 147 } 148 } 149 #endif 150 #ifndef KMK /* Inefficient! */ 125 151 process_adjust_wait_state(pproc); 152 #else 153 proc_index--; 154 if ((int)which < proc_index) 155 proc_array[which] = proc_array[proc_index]; 156 proc_array[proc_index] = NULL; 157 #endif 126 158 return pproc; 127 159 } else … … 133 165 */ 134 166 BOOL 135 process_kill(HANDLE proc, int signal)167 process_kill(HANDLE proc, int signal) 136 168 { 137 169 sub_process* pproc = (sub_process*) proc; 138 170 pproc->signal = signal; 171 #ifdef KMK 172 if (pproc->enmType == kRegular) { 173 #endif 139 174 return (TerminateProcess((HANDLE) pproc->pid, signal)); 175 #ifdef KMK 176 } else if (pproc->enmType == kSubmit) { 177 return kSubmitSubProcKill(pproc->clue, signal) == 0; 178 } 179 assert(0); 180 return FALSE; 181 #endif 140 182 } 141 183 … … 149 191 process_register(HANDLE proc) 150 192 { 193 #ifdef KMK 194 assert(((sub_process *)proc)->enmType == kRegular); 195 #endif 151 196 if (proc_index < MAXIMUM_WAIT_OBJECTS) 152 197 proc_array[proc_index++] = (sub_process *) proc; 153 198 } 199 200 #ifdef KMK 201 /** 202 * Interface used by kmkbuiltin/kSubmit.c to register stuff going down in a 203 * worker process. 204 * 205 * @returns 0 on success, -1 if there are too many sub-processes already. 206 * @param hEvent The event semaphore to wait on. 207 * @param clue The clue to base. 208 */ 209 int 210 process_kmk_register_submit(HANDLE hEvent, intptr_t clue) 211 { 212 if (proc_index < MAXIMUM_WAIT_OBJECTS) { 213 sub_process *pSubProc = (sub_process *)xcalloc(sizeof(*pSubProc)); 214 pSubProc->enmType = kSubmit; 215 pSubProc->clue = clue; 216 pSubProc->pid = (intptr_t)hEvent; 217 218 proc_array[proc_index++] = pSubProc; 219 return 0; 220 } 221 return -1; 222 } 223 #endif 154 224 155 225 /* … … 197 267 */ 198 268 #ifdef KMK 199 (void) process_file_io_private(pproc, FALSE); 269 if (pproc->enmType == kRegular) { 270 (void)process_file_io_private(pproc, FALSE); 271 } 200 272 #else 201 273 (void) process_file_io(pproc); … … 445 517 #ifdef KMK 446 518 size_t exec_path_len; 519 520 assert (pproc->enmType == kRegular); 447 521 #endif 448 522 … … 783 857 bool_t child_dead = FALSE; 784 858 BOOL GetExitCodeResult; 859 #ifdef KMK 860 assert (pproc->enmType == kRegular); 861 #endif 785 862 786 863 /* … … 918 995 } 919 996 997 #ifndef KMK /* unused */ 920 998 /* 921 999 * Purpose: collects output from child process and returns results … … 943 1021 return process_file_io_private(proc, TRUE); 944 1022 } 1023 #endif /* !KMK - unused */ 945 1024 946 1025 /* private function, avoid some kernel calls. (bird) */ … … 1024 1103 int i; 1025 1104 1105 #ifdef KMK 1106 if (pproc->enmType == kRegular) { 1107 #endif 1108 1026 1109 if (pproc->using_pipes) { 1027 1110 for (i= 0; i <= 1; i++) { … … 1036 1119 if ((HANDLE)pproc->pid) 1037 1120 CloseHandle((HANDLE)pproc->pid); 1121 #ifdef KMK 1122 } else if (pproc->enmType == kSubmit) { 1123 /* nothing to do. */ 1124 } else { 1125 assert(0); 1126 return; 1127 } 1128 pproc->enmType = kSubProcFreed; 1129 #endif 1038 1130 1039 1131 free(pproc);
Note:
See TracChangeset
for help on using the changeset viewer.
