From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 5CAE2BB81 for ; Mon, 8 Nov 2004 19:22:14 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iA8IMEgP000857 for ; Mon, 8 Nov 2004 19:22:14 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA11131 for ; Mon, 8 Nov 2004 19:22:13 +0100 (MET) Received: from appliedminds.com (mail.appliedminds.com [65.104.119.58]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iA8IMA6Q000842 for ; Mon, 8 Nov 2004 19:22:11 +0100 Received: from [10.10.10.55] (HELO appliedminds.com) by appliedminds.com (CommuniGate Pro SMTP 4.2.5) with ESMTP id 1122707 for caml-list@inria.fr; Mon, 08 Nov 2004 10:22:04 -0800 Received: from [10.11.15.35] (account jamesl HELO [10.11.15.35]) by appliedminds.com (CommuniGate Pro SMTP 4.2.5) with ESMTP id 698131 for caml-list@inria.fr; Mon, 08 Nov 2004 10:21:56 -0800 Message-ID: <418FB81F.7050100@appliedminds.com> Date: Mon, 08 Nov 2004 10:17:03 -0800 From: James Lamanna User-Agent: Mozilla Thunderbird 0.8 (X11/20040917) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Need help! - Unix.read always returning 0 X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 418FB956.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 418FB952.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 buffer:01 buffer:01 stdout:01 stdio:01 unistd:01 fcntl:01 argc:01 char:01 argv:01 struct:01 sizeof:01 printf:01 unix:01 unix:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: I really can't explain this, but Unix.read is always returning 0. I have the following simple Ocaml program: let buffer_length = 16 in let buffer = ref (String.create buffer_length) in let j = Unix.openfile "/dev/stick" [Unix.O_RDONLY] 0o666 in try while true do let n = Unix.read j !buffer 0 buffer_length in print_int n; print_string "\n"; flush stdout done with End_of_file -> () /dev/stick is a linux event device, so it should block. However, it does not block, and Unix.read consistently returns 0. However, the corresponding C program: #include #include #include #include int main(int argc, char **argv) { struct input_event ev; int fd = open("/dev/stick", O_RDONLY); while(1) { int r = read(fd, &ev, sizeof(ev)); printf("%d\n", r); } return 0; } Exhibits the desired behavior and reads correctly from the device. Any help? I'm kinda in a crunch on this. This behavior started when I moved to an AMD64 platform. Thank you. -- James Lamanna