Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Sep 2001 05:56:26 +0300
From:      Giorgos Keramidas <charon@labs.gr>
To:        Matt Dillon <dillon@earth.backplane.com>
Cc:        Ruslan Ermilov <ru@FreeBSD.ORG>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/bin/cat cat.1 cat.c
Message-ID:  <20010926055625.A21817@hades.hell.gr>
In-Reply-To: <200109251909.f8PJ9eJ03402@earth.backplane.com>
References:  <200109150039.f8F0dFZ41705@freefall.freebsd.org> <20010925211639.C57333@sunbay.com> <200109251909.f8PJ9eJ03402@earth.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Matt Dillon <dillon@earth.backplane.com> wrote:
> 
> :
> :How about testing with stat(2) that an argument is a socket
> :thus eliminating the need to open(2) sockets and connect(2)
> :to non-sockets?
> 
>     I don't see any particular reason why.  An open() failure is as fast
>     or faster then stat().  If it fails and we get the appropriate errno,
>     we try a connect().  Either connect() is supported or it isn't.  If it
>     is a case of a missing file we don't try the connect() because we get
>     a different errno.  I see no particular need to stat the path, no ill
>     effects will occur if the connect() fails.

And there is always a possibility of a race condition between a stat() and an
open().  So relying on stat() to control what open() and/or connect() will do
is kind of dangerous in my book :-/

-giorgos


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010926055625.A21817>