char *szCurrentDir;
pipex->state=0;
pipex->name=szName;
+ pipex->command=szProcFile;
+ pipex->quit_pending=FALSE;
pipex->hProcess=NULL;
if (szProcFile == NULL) {
pipex->hInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdInput = hStdinRead;
si.hStdOutput = hStdoutWrite;
si.hStdError = hStdoutWrite;
- if((szCurrentDir = _getcwd( NULL, 0 )) == NULL )
+ if((szCurrentDir = (char*)_getcwd( NULL, 0 )) == NULL )
my_fatal("pipex_open(): no current directory: %s\n",
strerror(errno));
if(_chdir(szWorkingDir)){
- my_fatal("pipex_open(): cannot change directory: %s\n",
+ my_fatal("pipex_open(): %s: %s\n",
+ szWorkingDir,
strerror(errno));
}
- if(CreateProcess(NULL,
+ if(CreateProcess(NULL,
(LPSTR) szProcFile,
NULL,
NULL,
pipex->bConsole = FALSE;
pipex->bPipe=TRUE;
}else{
- my_fatal("pipex_open(): %s",win32_error());
+ my_fatal("pipex_open(): %s: %s",szProcFile,win32_error());
}
_chdir(szCurrentDir);
}
// pipex_exit()
void pipex_exit(pipex_t *pipex) {
+ DWORD lpexit;
CloseHandle(pipex->hInput);
CloseHandle(pipex->hOutput);
- DWORD lpexit;
-
+ if(!pipex->quit_pending){
+ // suppress further errors
+ pipex->quit_pending=TRUE;
+ my_fatal("pipex_exit(): %s: child exited unexpectedly.\n",pipex->command);
+ }
if(GetExitCodeProcess(pipex->hProcess,&lpexit)){
if(lpexit==STILL_ACTIVE)
//must be java,hammer it down!
// pipex_set_affinit()
+typedef void (WINAPI *SPAM)(HANDLE, int);
void pipex_set_affinity(pipex_t *pipex, int value){
+ SPAM pSPAM;
+
if(pipex->hProcess) return;
if(value==-1) return;
- typedef void (WINAPI *SPAM)(HANDLE, int);
- SPAM pSPAM;
pSPAM = (SPAM) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
"SetProcessAffinityMask");