This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Process does not respond to signals on read() of win32 handle. (fwd)


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/

> > 

> > 

> 






--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]