Mail Archives: cygwin/2001/12/17/14:27:02
------_=_NextPart_000_01C18730.5E606480
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit
I've been looking into this problem myself, (see last month's thread
starting with http://www.cygwin.com/ml/cygwin/2001-11/msg01217.html )
and have gotten to this point: at the point where vfork is duplicating the
fhandler table and dup'ing open fh's it somehow isn't detecting that stdin
isn't connected to anything. (see dtable::vfork_child_dup () in dtable.cc,
line 553)
Where i'm stuck is figuring out why fh 0 has status of 0x18010 (FH_DISK,
FH_RBINSET, FH_SYMLINK). Shouldn't fh 0 point to stdin?
The file name is a null string, so there's no help there.
BTW, I've written a short windows program to launch make (which i've
recompiled with support for the -D switch, to give me time to attach gdb --
gdb'ing the test-make program doesn't seem to work) here it is:
<<test-make.c>>
It seems that there have been reports of this for gcc and make (my guess is
that it probably happens for all cygwin programs that launch other programs
as child processes) when launched using the windows CreateProcess API call.
Does anyone know how the cygwin dll handles CreateProcess calls in these
cases?
Warm Regards,
Chris
> -----Original Message-----
> From: Larry Hall (RFK Partners, Inc) [SMTP:lhall AT rfk DOT com]
> Sent: Monday, December 17, 2001 12:52 PM
> To: Suman Kumar Ray; cygwin AT cygwin DOT com
> Subject: Re: cygwin1.dll (file version 1003.6.0.0) dup problem with
> gcc
>
> At 01:40 PM 12/17/2001, Suman Kumar Ray wrote:
>
> >Hi,
> > In the mailing list, I have found this problem with
> >earlier dll but with no solution or information
> >whether this is a bug of cygwin.
> >If I use cygwin.dll file version 1003.6.0.0, then when
> >a windows GUI based IDE is calling gcc through
> >createprocess and pass a file for compilation error
> >message appears as
> >fhandler_base::dup: dup(unknown disk file) failed,
> >handle 0, Win32 error 6. If I use cygwin1.dll file
> >version 1003.2.0.0 ( I mean I put gcc in separate
> >directory and put 1003.2.0.0 cygwin1.dll there), no
> >problem in calling gcc from IDE. Interestingly, if I
> >open cygwin shell, within that I can compile using any
> >of the above dlls.
> > Can somebody please tell me, what is the problem, and
> >how to rectify it ?
> > I have tried following command after reading one
> >e-mail, but no success.
> > mount -b --change-cygdrive-prefix /cygdrive
>
> Right. This isn't a cygdrive issue so I wouldn't expect to see any
> significant change by altering the mount option here.
>
> Clearly, fhandler::dup() is getting an invalid handle ('net helpmsg 6'
> tells you that). Given that the handle is 0, I think it's clear that
> this complaint is valid. Beyond that though, you're going to need to
> dig a little deeper to find the root of the problem. The issue is
> internal, which would require debugging to find the cause and correct
> it. If you can, debugging Cygwin via gdb would be the best way to go.
> Alternatively, if you can't do that, calling gcc indirectly through
> strace in your IDE environment would provide some trace information
> that might help you or others better understand the problem.
>
> Good luck,
>
>
> Larry Hall lhall AT rfk DOT com
> RFK Partners, Inc. http://www.rfk.com
> 838 Washington Street (508) 893-9779 - RFK Office
> Holliston, MA 01746 (508) 893-9889 - FAX
>
>
> --
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting: http://cygwin.com/bugs.html
> Documentation: http://cygwin.com/docs.html
> FAQ: http://cygwin.com/faq/
>
------_=_NextPart_000_01C18730.5E606480
Content-Type: application/octet-stream;
name=test-make.c
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename=test-make.c
#include <stdio.h> =0A=
#define WIN32_LEAN_AND_MEAN=0A=
#include <windows.h> =0A=
=0A=
#define BUFSIZE 4096 =0A=
=0A=
#define IDW_STATUS 010=0A=
=0A=
=0A=
LRESULT WINAPI MainWndProc=0A=
( HWND, UINT, WPARAM, LPARAM );=0A=
BOOL=0A=
StatusWrite (char *);=0A=
BOOL =0A=
ReadFromPipe(HANDLE);=0A=
BOOL =0A=
CreateChildProcess(VOID);=0A=
=0A=
HWND hwndStatus; // handle to status window=0A=
HINSTANCE hInst; // current instance=0A=
HANDLE PipeReadHandle;=0A=
HANDLE PipeWriteHandle;=0A=
BOOL ReadPipeOK =3D FALSE;=0A=
=0A=
int WINAPI WinMain=0A=
( HINSTANCE hInstance,=0A=
HINSTANCE hPrevInstance,=0A=
LPSTR lpszCmdLine,=0A=
int nCmdShow=0A=
)=0A=
{ WNDCLASS wc;=0A=
MSG msg;=0A=
HWND hWnd;=0A=
=0A=
hInst =3D hInstance; // Store instance handle in our global =
variable=0A=
=0A=
wc.lpszClassName =3D "TestClass";=0A=
wc.lpfnWndProc =3D MainWndProc;=0A=
wc.style =3D CS_VREDRAW | CS_HREDRAW;=0A=
wc.hInstance =3D hInstance;=0A=
wc.hIcon =3D LoadIcon( NULL, IDI_APPLICATION );=0A=
wc.hCursor =3D LoadCursor( NULL, IDC_ARROW );=0A=
wc.hbrBackground =3D (HBRUSH) GetStockObject(WHITE_BRUSH);=0A=
wc.lpszMenuName =3D NULL;=0A=
wc.cbClsExtra =3D 0;=0A=
wc.cbWndExtra =3D 0;=0A=
RegisterClass( &wc );=0A=
=0A=
hWnd =3D CreateWindow=0A=
( wc.lpszClassName,=0A=
"Testing Make",=0A=
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,=0A=
0,=0A=
0,=0A=
CW_USEDEFAULT,=0A=
CW_USEDEFAULT,=0A=
NULL,=0A=
NULL,=0A=
hInstance,=0A=
NULL=0A=
);=0A=
=0A=
ShowWindow( hWnd, nCmdShow );=0A=
=0A=
while( GetMessage( &msg, NULL, 0, 0 ) )=0A=
{ TranslateMessage( &msg );=0A=
DispatchMessage( &msg );=0A=
if (ReadPipeOK)=0A=
{=0A=
ReadPipeOK =3D ReadFromPipe(PipeReadHandle);=0A=
} else {=0A=
StatusWrite("Read Pipe Failed");=0A=
}=0A=
}=0A=
return msg.wParam;=0A=
}=0A=
=0A=
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, =
LPARAM lParam )=0A=
{ PAINTSTRUCT ps;=0A=
HDC hDC;=0A=
=0A=
switch( msg )=0A=
{ case WM_CREATE:=0A=
// Create an MLE for status messages=0A=
hwndStatus =3D CreateWindow ("LISTBOX", // Class=0A=
NULL, // Window Name=0A=
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL, // Style=0A=
0, 0, 0, 0, // x, y, Width, Height=0A=
hWnd, // Parent Window=0A=
(HMENU) IDW_STATUS, // Child ID=0A=
hInst, // Application instance=0A=
NULL); // Window-creation data=0A=
Sleep(5);=0A=
StatusWrite("Creating Child Process");=0A=
if (CreateChildProcess()) {=0A=
StatusWrite("CreateChildProcess Completed OK");=0A=
ReadPipeOK =3D TRUE;=0A=
}=0A=
else {=0A=
StatusWrite("CreateChildProcess Completed Not OK");=0A=
}=0A=
break;=0A=
=0A=
case WM_PAINT:=0A=
hDC =3D BeginPaint( hWnd, &ps );=0A=
EndPaint( hWnd, &ps );=0A=
break;=0A=
=0A=
case WM_DESTROY:=0A=
PostQuitMessage( 0 );=0A=
break;=0A=
=0A=
case WM_SIZE:=0A=
// Make the edit control the size of the window's client area.=0A=
MoveWindow (hwndStatus, 0, 0, LOWORD (lParam), HIWORD (lParam), =
TRUE);=0A=
=0A=
default:=0A=
return( DefWindowProc( hWnd, msg, wParam, lParam ));=0A=
}=0A=
return 0;=0A=
}=0A=
=0A=
//----------------------------------------------------------------------=
-----=0A=
// FUNCTION: StatusWrite ( char * szText )=0A=
// COMMENTS: Writes the specified string to the status window=0A=
//=0A=
// Uses the buffer pointed to by =
hmemStatusBuf (of size MAX_STATUS_BUFFER)=0A=
// (effectively a zero-terminated =
string)=0A=
// Converts \n to \r\n for proper =
line-breaks=0A=
//=0A=
// Returns FALSE if no error, TRUE if =
error locating buffer=0A=
//----------------------------------------------------------------------=
-----=0A=
=0A=
void=0A=
AppendText (char *szText)=0A=
{=0A=
=0A=
DWORD dwLogLength;=0A=
const DWORD dwMAX_LOG_LENGTH =3D 10000;=0A=
=0A=
=0A=
dwLogLength =3D SendMessage (hwndStatus, LB_GETCOUNT, 0, 0);=0A=
=0A=
while (dwLogLength > dwMAX_LOG_LENGTH)=0A=
{=0A=
SendMessage (hwndStatus, LB_DELETESTRING, (WPARAM) 0,=0A=
(LPARAM) 0);=0A=
-- dwLogLength;=0A=
}=0A=
=0A=
// insert text=0A=
SendMessage (hwndStatus, LB_INSERTSTRING, (WPARAM) dwLogLength, =
(LPARAM) szText);=0A=
=0A=
=0A=
}=0A=
=0A=
BOOL=0A=
StatusWrite (char *szText)=0A=
{=0A=
=0A=
char szBuffer[BUFSIZ];=0A=
char *szCurrentPosition =3D szText;=0A=
char *szEnd =3D szText + strlen (szText);=0A=
char *szLineEnd;=0A=
int HasCR =3D 0;=0A=
=0A=
=0A=
while (szCurrentPosition < szEnd)=0A=
{=0A=
=0A=
memset (szBuffer, (int) '\0', BUFSIZ);=0A=
=0A=
if ((szLineEnd =3D strchr (szCurrentPosition, (int) '\n')) =3D=3D =
0)=0A=
szLineEnd =3D szEnd;=0A=
=0A=
if (*(szLineEnd - 1) =3D=3D '\r')=0A=
HasCR =3D 1;=0A=
else=0A=
HasCR =3D 0;=0A=
=0A=
strncat (szBuffer, szCurrentPosition,=0A=
(int) ((szLineEnd - HasCR) - szCurrentPosition));=0A=
szCurrentPosition =3D szLineEnd + 1;=0A=
=0A=
AppendText (szBuffer);=0A=
}=0A=
=0A=
=0A=
return (FALSE);=0A=
=0A=
}=0A=
=0A=
=0A=
=0A=
=0A=
BOOL CreateChildProcess(VOID) =0A=
{ =0A=
SECURITY_ATTRIBUTES SecurityAttributes;=0A=
STARTUPINFO StartupInfo;=0A=
PROCESS_INFORMATION ProcessInfo;=0A=
=0A=
ZeroMemory( &StartupInfo, sizeof( StartupInfo ));=0A=
ZeroMemory( &ProcessInfo, sizeof( ProcessInfo ));=0A=
ZeroMemory( &SecurityAttributes, sizeof( SecurityAttributes ));=0A=
=0A=
SecurityAttributes.nLength =3D =
sizeof(SECURITY_ATTRIBUTES);=0A=
SecurityAttributes.bInheritHandle =3D TRUE;=0A=
SecurityAttributes.lpSecurityDescriptor =3D NULL;=0A=
=0A=
CreatePipe=0A=
(=0A=
&PipeReadHandle, // address of variable for read handle=0A=
&PipeWriteHandle, // address of variable for write handle=0A=
&SecurityAttributes, // pointer to security attributes=0A=
0 // default num bytes reserved for pipe=0A=
);=0A=
=0A=
StartupInfo.cb =3D sizeof(STARTUPINFO);=0A=
StartupInfo.dwFlags =3D STARTF_USESHOWWINDOW | =
STARTF_USESTDHANDLES;=0A=
StartupInfo.wShowWindow =3D SW_HIDE;=0A=
StartupInfo.hStdOutput =3D PipeWriteHandle;=0A=
StartupInfo.hStdError =3D PipeWriteHandle;=0A=
=0A=
return CreateProcess=0A=
( =0A=
NULL, // pointer to name of executable module=0A=
//LPTSTR(=0A=
"c:\\cygwin\\bin\\make.exe -D test-cygwin",//), // command line =0A=
NULL, // pointer to process security attributes =0A=
NULL, // pointer to thread security attributes (use primary thread =
security attributes)=0A=
TRUE, // inherit handles=0A=
0, // creation flags=0A=
NULL, // pointer to new environment block(use parent's)=0A=
"c:\\cygwin\\usr\\local\\src\\test-make", // pointer to current =
directory name=0A=
&StartupInfo, // pointer to STARTUPINFO=0A=
&ProcessInfo // pointer to PROCESS_INFORMATION=0A=
);=0A=
}=0A=
=0A=
=0A=
BOOL ReadFromPipe(HANDLE hFile) =0A=
{ =0A=
DWORD dwRead, dwBytesAvaliable, dwBytesLeft; =0A=
char chBuf[BUFSIZE]; =0A=
=0A=
// Read output from the child process, and write to parent's STDOUT. =
=0A=
=0A=
memset (chBuf, (int) '\0', BUFSIZ);=0A=
if( !PeekNamedPipe( hFile, chBuf, BUFSIZE, &dwRead, =0A=
&dwBytesAvaliable, &dwBytesLeft) ) =0A=
{=0A=
return FALSE; =0A=
} else if ( dwBytesAvaliable !=3D 0 &&=0A=
ReadFile( hFile, chBuf, BUFSIZE, &dwRead, =0A=
NULL) && dwRead !=3D 0)=0A=
{=0A=
chBuf[dwRead] =3D 0;=0A=
StatusWrite(chBuf);=0A=
}=0A=
return TRUE;=0A=
} =0A=
=0A=
------_=_NextPart_000_01C18730.5E606480
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------_=_NextPart_000_01C18730.5E606480--
- Raw text -