Bug #3323 ยป CreateChild.patch
| win32/win32.c (working copy) | ||
|---|---|---|
|
{
|
||
|
BOOL fRet;
|
||
|
DWORD dwCreationFlags;
|
||
|
STARTUPINFO aStartupInfo;
|
||
|
STARTUPINFOW aStartupInfo;
|
||
|
PROCESS_INFORMATION aProcessInformation;
|
||
|
SECURITY_ATTRIBUTES sa;
|
||
|
struct ChildRecord *child;
|
||
|
|
||
|
WCHAR* wprog = NULL;
|
||
|
WCHAR* wcmd = NULL;
|
||
|
if (!cmd && !prog) {
|
||
|
errno = EFAULT;
|
||
| ... | ... | |
|
psa = &sa;
|
||
|
}
|
||
|
memset(&aStartupInfo, 0, sizeof (STARTUPINFO));
|
||
|
if (!(wprog = utf8_to_wstr(prog, NULL)) || !(wcmd = utf8_to_wstr(cmd, NULL)))
|
||
|
{
|
||
|
free(wcmd);
|
||
|
free(wprog);
|
||
|
|
||
|
return NULL;
|
||
|
}
|
||
|
memset(&aStartupInfo, 0, sizeof (STARTUPINFOW));
|
||
|
memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION));
|
||
|
aStartupInfo.cb = sizeof (STARTUPINFO);
|
||
|
aStartupInfo.cb = sizeof (STARTUPINFOW);
|
||
|
aStartupInfo.dwFlags = STARTF_USESTDHANDLES;
|
||
|
if (hInput) {
|
||
|
aStartupInfo.hStdInput = hInput;
|
||
| ... | ... | |
|
dwCreationFlags = (NORMAL_PRIORITY_CLASS);
|
||
|
RUBY_CRITICAL({
|
||
|
fRet = CreateProcess(prog, (char *)cmd, psa, psa,
|
||
|
fRet = CreateProcessW(wprog, wcmd, psa, psa,
|
||
|
psa->bInheritHandle, dwCreationFlags, NULL, NULL,
|
||
|
&aStartupInfo, &aProcessInformation);
|
||
|
errno = map_errno(GetLastError());
|
||
|
});
|
||
|
|
||
|
free(wcmd);
|
||
|
free(wprog);
|
||
|
if (!fRet) {
|
||
|
child->pid = 0; /* release the slot */
|
||