Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Nov 2000 11:52:45 +0100 (CET)
From:      bbl@dk.damgaard.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/23173: read hangs in linux emulation 
Message-ID:  <200011291052.eATAqjW13768@alpha.intern.dd.dk>

next in thread | raw e-mail | index | archive | help

>Number:         23173
>Category:       kern
>Synopsis:       read hangs in linux emulation
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 29 03:00:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Bjarne Blichfeldt
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
>Environment:

	

>Description:

The following testprogram wil demonstrate an error in linux compatibility
between linux and freebsd, both on intelplatform.
The program is compiled on an intel linux Slackware 7.0 with gcc 2.95.2 and
the binary is then copied to FreeBSD 4.2-stable.
The problem is seen both on 4.1 and 4.2

The correct behaviour on linux, is to read a charcter on stdin, provided
there is one, othervise return 0.

On FreeBSD, the read will just hang until a key is pressed. 
After a key is pressed, the character is returned after aprox. 20 seconds.


If 
   st_tbuf.c_cc[VTIME] = 0;  

is changed to 
   st_tbuf.c_cc[VTIME] = 100; 

the read is supposed to wait max. 10 seconds, whereafter 0 is returned.

On FreeBSD, read will hang indefinitely, until a key is pressed. 
After a key is pressed, read will return after aprox. 20 seconds.
	

>How-To-Repeat:

#include <stdio.h>
#include <termios.h>
#include <unistd.h>


struct termios st_tbuf, old_st;

main () {
   char buf [256];
   int  ret;


  ret = tcgetattr(0, &old_st);

  st_tbuf.c_lflag &= ~(ICANON | ECHO);
  st_tbuf.c_cc[VMIN]  = 0;
  st_tbuf.c_cc[VTIME] = 0;
  ret = tcsetattr(0, TCSANOW, &st_tbuf);

  ret = read (0, (char *)buf, 1);

  tcsetattr(0, TCSANOW, &old_st);

  if (ret > 0)   printf ("inp = %c\n", buf[0]);
  else           printf ("Zip\n");
}


>Fix:

	


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011291052.eATAqjW13768>