Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261556AbTISNFR (ORCPT ); Fri, 19 Sep 2003 09:05:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261563AbTISNFQ (ORCPT ); Fri, 19 Sep 2003 09:05:16 -0400 Received: from chaos.analogic.com ([204.178.40.224]:55937 "EHLO chaos.analogic.com") by vger.kernel.org with ESMTP id S261556AbTISNFJ (ORCPT ); Fri, 19 Sep 2003 09:05:09 -0400 Date: Fri, 19 Sep 2003 09:06:46 -0400 (EDT) From: "Richard B. Johnson" X-X-Sender: root@chaos Reply-To: root@chaos.analogic.com To: Hugang cc: Linux kernel Subject: Re: use O_DIRECT open file, when read will hang. In-Reply-To: <20030919124631.3b4e6301.hugang@soulinfo.com> Message-ID: References: <20030919124631.3b4e6301.hugang@soulinfo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1452 Lines: 57 On Fri, 19 Sep 2003, Hugang wrote: Your script cannot work. Also, nothing hangs. > Hello all: > > Steps to reproduce: > > rm -f /tmp/1.log > touch /tmp/1.log > echo << EOF > /tmp/hang.c ^^^^______ cat, not echo > #include > #include > > main() > { > int i; > char buf[1025]; > > i = open("/tmp/1.log", O_RDONLY | 040000, 0); > if ( i != -1) { > read(i, buf, 1); > } > printf("'%s'", buf); > } > EOF > gcc -o /tmp/hang /tmp/hang.c > /tmp/hang > > This is a `strace` of it working: getpid() = 14243 open("/tmp/1.log", O_RDONLY|0x4000) = 3 read(3, "", 1) = 0 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(4, 1), ...}) = 0 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400aa000 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 write(1, "\'\'", 2) = 2 munmap(0x400aa000, 4096) = 0 _exit(2) = ? Cheers, Dick Johnson Penguin : Linux version 2.4.22 on an i686 machine (794.73 BogoMips). Note 96.31% of all statistics are fiction. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/