--- ray/src/common/win_process.c 2005/09/19 11:30:10 3.6 +++ ray/src/common/win_process.c 2014/02/12 00:15:40 3.9 @@ -1,5 +1,5 @@ #ifndef lint -static char RCSid[]="$Id: win_process.c,v 3.6 2005/09/19 11:30:10 schorsch Exp $"; +static char RCSid[]="$Id: win_process.c,v 3.9 2014/02/12 00:15:40 greg Exp $"; #endif /* * Routines to communicate with separate process via dual pipes. @@ -167,8 +167,8 @@ start_process(SUBPROC *proc, char *cmdstr) CloseHandle(hFromChildWrite); hFromChildWrite = NULL; CloseHandle(hToChildRead); hToChildRead = NULL; /* get the file descriptors */ - proc->r = _open_osfhandle((long)hRead, _O_RDONLY); - proc->w = _open_osfhandle((long)hWrite, _O_APPEND); + proc->r = _open_osfhandle((long)hRead, _O_RDONLY|_O_BINARY); + proc->w = _open_osfhandle((long)hWrite, _O_APPEND|_O_BINARY); proc->pid = PInfo.dwProcessId; proc->running = 1; CloseHandle(hCurProc); @@ -185,7 +185,7 @@ error: /* cleanup */ if(hWrite) CloseHandle(hWrite); if(hCurProc) CloseHandle(hCurProc); proc->running = 0; - return 0; + return -1; /* There... Are we happy now? */ } @@ -279,7 +279,12 @@ open_process(SUBPROC *proc, char *av[]) char *cmdpath; char *cmdstr; + if (av == NULL || av[0] == NULL) { + fputs("Illegal call to open_process()!\n", stderr); + return -1; + } proc->running = 0; + if (av == NULL) { return -1; } cmdpath = getpath(av[0], getenv("PATH"), X_OK); cmdstr = quoted_cmdline(cmdpath, av+1); if (cmdstr == NULL) { return 0; }