Bug 15553

Summary: Linux Emulation don't emulate accept(2) exactly
Product: Base System Reporter: kumabu <kumabu>
Component: i386Assignee: Marcel Moolenaar <marcel>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.1-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description kumabu 1999-12-18 21:30:00 UTC
Linux's accept(2) seems new socket doesn't inherit listening
socket's file flags.(though RedHat's accept(2) man describes
``creates a new socket with the same properties of s ...'')
But FreeBSD's accept(2) creates new socket with the exactly
same properties of parent. And same the Linux Emulation.
(SunOS 5.x is same, 4.x not)
So some Linux program under emulation doesn't work correctly.

Fix: I modified /sys/i386/linux/linux_socket.c(1.16) as below diff
and Linux (blackdown's)JDK works expectedly.
I don't know this is appropriate at all,
but the least O_NONBLOCK shouldn't be inherited to new socket
in Linux Emulation mode.
How-To-Repeat: // simple test code in C
socket() & bind() & listen()
fcntl(sock, F_SETFL, O_NONBLOCK | fcntl(sock, F_GETFL, 0));
printf("0x%08x\n", fcntl(sock, F_GETFL));
new_sock = accept(...);
printf("0x%08x\n", fcntl(new_sock, F_GETFL));
// Linux(non emulation) blocks here, but emulation occurs EAGAIN
read(new_sock, buf, 1);

I found this in linux JDK1.2pre-v2(& 1.2.2-RC3) with emulation.
// in Java code
Socket sock = new ServerSocket(3000).accept();
// read() causes Exception on Linux Emulation,
// if no available data has received
sock.getInputStream().read();
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-07 15:41:01 UTC
Responsible Changed
From-To: freebsd-bugs->marcel

Marcel, this one includes a patch. :-)
Comment 2 Marcel Moolenaar freebsd_committer freebsd_triage 2000-11-13 05:08:02 UTC
State Changed
From-To: open->closed

Problem does not exist anymore (fixed as part of PR 16946).