* FW: Process does not respond to signals on read() of win32 handle.
@ 2002-11-06 13:24 Harig, Mark A.
0 siblings, 0 replies; only message in thread
From: Harig, Mark A. @ 2002-11-06 13:24 UTC (permalink / raw)
To: sanjayl, cygwin
Please send all replies to the Cygwin users' mailing list.
This serves two purposes:
1. More people can see your problem description. This
will increase the chance that someone will know a
solution to your problem.
2. The problem and its solution are added to the
mailing-list archives. This is one of the main
knowledge databases for Cygwin. Even if a solution
is not found, then other readers are made aware of
the problem and know that it is not unique to them.
> -----Original Message-----
> From: sanjayl@mindspring.com [mailto:sanjayl@mindspring.com]
> Sent: Wednesday, November 06, 2002 4:20 PM
> To: Harig, Mark A.
> Subject: RE: Process does not respond to signals on read() of win32
> handle.
>
>
> Hi Mark,
>
> I am running Cygwin on Windows 2000. Here is the output of uname -a
>
> CYGWIN_NT-5.0 REDBSUNJAY1 1.3.14(0.62/3/2) 2002-10-24 10:48
> i686 unknown
>
> And here is a short program that can reproduce the bug. I
> just CreateFile()
> COM0 and then map it to a cygwin file desciptor. I then
> read() on the fd. At
> this point the program stops responding to any signals
> (CTRL-C) etc, until
> some data shows up on the device to wake up the read. I just
> use g++ com.cpp
> to compile the executable.
>
> Thanks again for all your help.
> Sanjay
>
> ================================================
> #include <windows.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> #ifdef __CYGWIN__
> #include <unistd.h>
> #include <sys/fcntl.h>
> #include <errno.h>
>
> extern "C" int cygwin_attach_handle_to_fd (char *name, int
> fd, HANDLE handle,
> int bin, int access);
>
> extern "C" void cygwin_conv_to_full_posix_path (const char *path,char
> *posix_path);
> #endif /* __CYGWIN__ */
>
> int
> main (void)
> {
>
> /* Open the file */
> int fd = -1;
> HANDLE m_Handle = INVALID_HANDLE_VALUE;
>
> m_Handle = CreateFile
> ("\\\\.\\COM1",
> GENERIC_READ | GENERIC_WRITE,
> FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0);
>
>
> if (m_Handle == INVALID_HANDLE_VALUE)
> {
> printf ("Create file on device failed\n");
> }
>
> fd = cygwin_attach_handle_to_fd ("/dev/tap", -1, m_Handle,
> 1, GENERIC_READ | GENERIC_WRITE);
>
> printf ("Cygwin fd: %d\n", fd);
> char *Data = (char *) malloc (4096);
>
> int BytesRead;
> while (1)
> {
> if ((BytesRead = read (fd, Data, 1500)) < 0)
> {
> printf ("read() error: %d\n", errno);
> exit(errno);
> }
>
> printf ("Read %d bytes\n", BytesRead);
> }
>
> free (Data);
> }
> ============CUT HERE=======================
>
>
>
>
> > Source code of a small program that reproduces
> > your problem,
> > along with the commands you used to compile,
> > link, and run
> > the program would likely increase the chances
> > that someone
> > can and will help with this problem.
> >
> > > -----Original Message-----
> > > From: sanjayl@mindspring.com
> > [mailto:sanjayl@mindspring.com]
> > > Sent: Wednesday, November 06, 2002 1:51 PM
> > > To: cygwin@cygwin.com
> > > Subject: Process does not respond to signals
> > on read() of
> > > win32 handle.
> > >
> > >
> > > I have a program that opens a Win2k driver
> > using CreateFile and then
> > > associates it with a file desciprtor using
> > > cygwin_attach_handle_to_fd().
> > > I then do a read() on the descriptor. At this
> > point the program stops
> > > responding to CTRL-Cs etc. until something is
> > written to the
> > > device and
> > > the read() returns. Only then is the signal
> > caught and the
> > > process exits.
> > >
> > > I have tried the same program in a pure Win32
> > environment
> > > using CreateFile()
> > > and ReadFile() calls, and things seem to
> > > work as expected.
> > >
> > > Any help would be greatly appreciated.
> > >
> > > Thanks in advance,
> > > Sanjay
> > >
--
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/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-06 21:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-06 13:24 FW: Process does not respond to signals on read() of win32 handle Harig, Mark A.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).