From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 10 15:02:56 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 22EFB1065781; Tue, 10 Jul 2012 15:02:56 +0000 (UTC) (envelope-from c.kworr@gmail.com) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6A1058FC14; Tue, 10 Jul 2012 15:02:55 +0000 (UTC) Received: by bkcje9 with SMTP id je9so85958bkc.13 for ; Tue, 10 Jul 2012 08:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=RZRfuKFOwkFeC+V3NRXnWkIWY8zwesP6dII6YQlflVQ=; b=pfOLyD2FV8tpn6Ye4y0Yx4Wz0zn/iJ1g3UtmGCc1Ag1aBTXebaNvJ7bo6BRaXa8bVX 7S3E84knOCv8OcEz/4GsDsInlllEGiZa0TrJiD7jol341WPRRSzokcygbk/PGK4mrHwq IhiW+zbLlDhz8O0TZP5F951M4O+TCXa7t2nr1t/ikN6SfzLHCtbHWStsSVSOJcRiftRl 8FPlknSWZI25GPBk9gjKfw8tGE9DuMnt1R7r0kceLwCFEyr6TPmyUQbhrK/TGyrDC1mj RWPjqLxRuT5i0BU97i0UKtNZ6wMHJQLJWteXoeMyqxdZHh71e/RZxl5V1HZu2UymZgxk /DTA== Received: by 10.205.128.141 with SMTP id he13mr15452938bkc.112.1341932574438; Tue, 10 Jul 2012 08:02:54 -0700 (PDT) Received: from green.tandem.local (utwig.xim.bz. [91.216.237.46]) by mx.google.com with ESMTPS id t23sm20751813bks.4.2012.07.10.08.02.51 (version=SSLv3 cipher=OTHER); Tue, 10 Jul 2012 08:02:53 -0700 (PDT) Message-ID: <4FFC441A.2010500@gmail.com> Date: Tue, 10 Jul 2012 18:02:50 +0300 From: Volodymyr Kostyrko User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120605 Firefox/12.0 SeaMonkey/2.9.1 MIME-Version: 1.0 To: Konstantin Belousov References: <4FFC1D2D.4020405@gmail.com> <20120710140203.GA2338@deviant.kiev.zoral.com.ua> <4FFC39D9.6080809@gmail.com> <20120710142746.GD2338@deviant.kiev.zoral.com.ua> In-Reply-To: <20120710142746.GD2338@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "freebsd-hackers@freebsd.org" , freebsd-standards@freebsd.org Subject: Re: kern/149857: [kqueue] kqueue not reporting EOF under certain circumstances X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 15:02:56 -0000 Konstantin Belousov wrote: >> So you mean this is just my false assumption that EOF _should_ occur on >> stdin? And it actually occurs only if source is a process which can send >> EOF? > > 'Source' cannot be a process. Read filter on pipes can return EV_EOF. > Read filter on vnodes (read: regular files) does not return EV_EOF, > except in situation that is created by manual intervention of > administrator. This keeps me puzzled. How then I can tell that file at stdin is already at EOF? You mean I should treat stdin like normal vnode-backed file? off_t pos = 0, endpos; lseek(fileno(stdin), 0, SEEK_END); endpos = ftell(stdin); lseek(fileno(stdin), 0, SEEK_SET); ... and then later check it with: if(endpos != -1) { pos += kev.data; if(pos >= endpos) { printf("end reached\n"); return(0); } } Is this a correct way to detect EOF? I'm letting besides that I should also detect vnode changes and update max file size accordingly. > It should have been clear from my previous response. Please excuse me, I'm a bit new to this things... -- Sphinx of black quartz judge my vow.