From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 9 22:20:53 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 DB57910656BE for ; Mon, 9 Mar 2009 22:20:53 +0000 (UTC) (envelope-from timothy@redaelli.eu) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id A267F8FC20 for ; Mon, 9 Mar 2009 22:20:53 +0000 (UTC) (envelope-from timothy@redaelli.eu) Received: by an-out-0708.google.com with SMTP id b38so873794ana.13 for ; Mon, 09 Mar 2009 15:20:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.99.201 with SMTP id v9mr2119587vcn.50.1236635319109; Mon, 09 Mar 2009 14:48:39 -0700 (PDT) Date: Mon, 9 Mar 2009 22:48:39 +0100 Message-ID: From: Timothy Redaelli To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: 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 22:20:54 -0000 Hi, 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. 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/