3228 fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput); |
3228 fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput); |
3229 fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput); |
3229 fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput); |
3230 fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError); |
3230 fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError); |
3231 #endif |
3231 #endif |
3232 } else { |
3232 } else { |
3233 fprintf(stderr, "Win32OS: bad fd arg in createProcess\n"); |
3233 fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n"); |
3234 } |
3234 } |
3235 |
3235 |
3236 if (doFork == true) { |
3236 if (doFork == true) { |
3237 #ifdef PROCESSDEBUGWIN32 |
3237 #ifdef PROCESSDEBUGWIN32 |
3238 fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir); |
3238 fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir); |
3525 if (create == 0) { |
3525 if (create == 0) { |
3526 fileHandle = nil; |
3526 fileHandle = nil; |
3527 argumentError = @symbol(missingCreateMode); |
3527 argumentError = @symbol(missingCreateMode); |
3528 goto badArgument; |
3528 goto badArgument; |
3529 } |
3529 } |
3530 fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n", |
3530 #ifdef PROCESSDEBUGWIN32 |
|
3531 fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n", |
3531 name, access, share, create, attr); |
3532 name, access, share, create, attr); |
3532 |
3533 #endif |
3533 h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */); |
3534 h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */); |
3534 if (h != INVALID_HANDLE_VALUE) { |
3535 if (h != INVALID_HANDLE_VALUE) { |
3535 __externalAddressVal(fileHandle) = (void *)h; |
3536 __externalAddressVal(fileHandle) = (void *)h; |
3536 } else { |
3537 } else { |
3537 fileHandle = nil; |
3538 fileHandle = nil; |
5097 "/ or not supported by OS |
5098 "/ or not supported by OS |
5098 "/ |
5099 "/ |
5099 ^ self primitiveFailed |
5100 ^ self primitiveFailed |
5100 ! |
5101 ! |
5101 |
5102 |
5102 terminateProcess:processId |
5103 terminateProcess:processHandle |
5103 "terminate a process. |
5104 "terminate a process. |
5104 The process has a chance to do some cleanup. |
5105 The process has a chance to do some cleanup. |
5105 WIN32: |
5106 WIN32: |
5106 Under unix, we have terminateProcess, which does a soft |
5107 Under unix, we have terminateProcess, which does a soft |
5107 terminate (giving the process a chance to cleanup) and |
5108 terminate (giving the process a chance to cleanup) and |
5112 Use it only in extreme circumstances. The state of |
5113 Use it only in extreme circumstances. The state of |
5113 global data maintained by dynamic-link libraries (DLLs) |
5114 global data maintained by dynamic-link libraries (DLLs) |
5114 may be compromised if TerminateProcess is used. |
5115 may be compromised if TerminateProcess is used. |
5115 TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
5116 TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
5116 |
5117 |
5117 self terminateProcess:processId exitCode:0 |
5118 self terminateProcess:processHandle exitCode:0 |
5118 ! |
5119 ! |
5119 |
5120 |
5120 terminateProcess:processId exitCode:exitCode |
5121 terminateProcess:processHandle exitCode:exitCode |
5121 "terminate a process. |
5122 "terminate a process. |
5122 The process should have a chance to do some cleanup. |
5123 The process should have a chance to do some cleanup. |
5123 WIN32: |
5124 WIN32: |
5124 Under unix, we have terminateProcess, which does a soft |
5125 Under unix, we have terminateProcess, which does a soft |
5125 terminate (giving the process a chance to cleanup) and |
5126 terminate (giving the process a chance to cleanup) and |
5131 global data maintained by dynamic-link libraries (DLLs) |
5132 global data maintained by dynamic-link libraries (DLLs) |
5132 may be compromised if TerminateProcess is used. |
5133 may be compromised if TerminateProcess is used. |
5133 TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
5134 TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
5134 |
5135 |
5135 %{ |
5136 %{ |
5136 if (__isExternalAddressLike(processId) ) { |
5137 if (__isExternalAddressLike(processHandle) ) { |
5137 HANDLE hProcess = _HANDLEVal(processId); |
5138 HANDLE hProcess = _HANDLEVal(processHandle); |
5138 |
5139 |
5139 #ifdef PROCESS1DEBUGWIN32 |
5140 #ifdef PROCESS1DEBUGWIN32 |
5140 printf("TerminateProcess handle: %x\n", hProcess); |
5141 printf("TerminateProcess handle: %x\n", hProcess); |
5141 #endif |
5142 #endif |
5142 if (hProcess != 0) { |
5143 if (hProcess != 0) { |
5143 TerminateProcess(hProcess, __intVal(exitCode)); |
5144 TerminateProcess(hProcess, __intVal(exitCode)); |
5144 } |
5145 } else { |
5145 } |
5146 fprintf(stderr, "Win32OS [warning]: wrong hProcess in TerminateProcess\n"); |
5146 #ifdef PROCESS1DEBUGWIN32 |
5147 } |
5147 else { |
5148 } else { |
5148 printf("TerminateProcess wrong handle\n"); |
5149 fprintf(stderr, "Win32OS [warning]: wrong processHandle in TerminateProcess\n"); |
5149 } |
5150 } |
5150 #endif |
|
5151 %} |
5151 %} |
5152 |
5152 |
5153 "Modified: / 28.12.1995 / 15:05:37 / stefan" |
5153 "Modified: / 28.12.1995 / 15:05:37 / stefan" |
5154 "Modified: / 27.1.1998 / 20:05:47 / cg" |
5154 "Modified: / 27.1.1998 / 20:05:47 / cg" |
5155 ! |
5155 ! |
5156 |
5156 |
5157 terminateProcessGroup:processGroupHandle |
5157 terminateProcessGroup:processGroupHandle |
5158 "terminate a process group. |
5158 "terminate a process group. |
5159 The processes should have a chance to do some cleanup. |
5159 The processes should have a chance to do some cleanup. |
5160 WIN32: |
5160 WIN32: |
5161 The TerminateProcess function is used to unconditionally cause |
5161 The processGroup is terminated by sending it a CTRL-C |
5162 a process to exit. |
5162 using GenerateConsoleCtrlEvent." |
5163 Use it only in extreme circumstances. The state of |
|
5164 global data maintained by dynamic-link libraries (DLLs) |
|
5165 may be compromised if TerminateProcess is used. |
|
5166 Not implemented - TODO: enumerate all sub-processes and terminate them all ..." |
|
5167 |
5163 |
5168 %{ |
5164 %{ |
5169 if (__isExternalAddressLike(processGroupHandle) ) { |
5165 if (__isExternalAddressLike(processGroupHandle) ) { |
5170 HANDLE hProcessGroup = _HANDLEVal(processGroupHandle); |
5166 HANDLE hProcessGroup = _HANDLEVal(processGroupHandle); |
5171 DWORD processGroupId = _HANDLEVal(processGroupHandle); |
5167 DWORD processGroupId; |
5172 |
5168 |
5173 processGroupId = __intVal( ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(processGroupHandle))->pid ); |
5169 if (hProcessGroup != (HANDLE)0) { |
|
5170 processGroupId = __intVal( ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(processGroupHandle))->pid ); |
5174 |
5171 |
5175 #ifdef PROCESS1DEBUGWIN32 |
5172 #ifdef PROCESS1DEBUGWIN32 |
5176 printf("TerminateProcessGroup processGroupHandle: %x (%d)\n", hProcessGroup, processGroupId); |
5173 printf("TerminateProcessGroup processGroupHandle: %x (%d)\n", hProcessGroup, processGroupId); |
5177 #endif |
5174 #endif |
5178 if (hProcessGroup != 0) { |
|
5179 GenerateConsoleCtrlEvent(CTRL_C_EVENT, processGroupId); |
5175 GenerateConsoleCtrlEvent(CTRL_C_EVENT, processGroupId); |
5180 } |
5176 } else { |
5181 } |
5177 fprintf(stderr, "Win32OS [warning]: wrong hProcessGroup in TerminateProcessGroup \n"); |
5182 #ifdef PROCESS1DEBUGWIN32 |
5178 } |
5183 else { |
5179 } else { |
5184 printf("TerminateProcessGroup wrong processGroupHandle\n"); |
5180 fprintf(stderr, "Win32OS [warning]: wrong processGroupHandle in TerminateProcessGroup \n"); |
5185 } |
5181 } |
5186 #endif |
|
5187 %} |
5182 %} |
5188 ! ! |
5183 ! ! |
5189 |
5184 |
5190 !Win32OperatingSystem class methodsFor:'ipc support'! |
5185 !Win32OperatingSystem class methodsFor:'ipc support'! |
5191 |
5186 |