From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 9 23:35:59 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E247106566C for ; Mon, 9 Mar 2009 23:35:59 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 397BA8FC17 for ; Mon, 9 Mar 2009 23:35:59 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id CC24146B03; Mon, 9 Mar 2009 19:35:58 -0400 (EDT) Date: Mon, 9 Mar 2009 23:35:58 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Timothy Redaelli In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org Subject: Re: lockf: Invalid argument on pipe 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: Mon, 09 Mar 2009 23:35:59 -0000 On Mon, 9 Mar 2009, Timothy Redaelli wrote: > Why can't I do a lockf on a file descriptor that does not point a real file > (such as stderr, stdout, or a character device)? > > Since it works under NetBSD, Linux, Solaris. For portability between systems > I hope I can do it under FreeBSD. > > The following code is simple, but It reproduce the problem. Under > non-FreeBSD systems, It will block before the puts. Instead under FreeBSD > the lockf calls return error and, so, the lock does not works. Could you file a PR for this, with pretty much this e-mail and sample code included? There's no real reason not for it to work other than that it is likely not implemented for devfs; that should be easy to fix it but opening a PR will help us keep track of the fact that it wants to be fixed. thanks, Robert N M Watson Computer Laboratory University of Cambridge > > Any suggest? > > > #include > #include > #include > #include > > int main(int argc, char *argv[]) { > char tmp[256]; > > if (lockf(2, F_LOCK, 0) == -1) > perror("lock"); > snprintf (tmp, 256, "%s XXX", argv[0]); > if (!argv[1] || strcmp(argv[1], "XXX")) > system(tmp); > puts("You should see it only after ctrl+c"); > return EXIT_SUCCESS; > } > > > -- > Timothy Redaelli > IT Consultant > Email: timothy@redaelli.eu > Mobile: +39 (338) 1187273 > WWW: http://www.redaelli.eu/ > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >