From owner-freebsd-questions Fri Nov 19 8:41: 1 1999 Delivered-To: freebsd-questions@freebsd.org Received: from mojave.sitaranetworks.com (mojave.sitaranetworks.com [199.103.141.157]) by hub.freebsd.org (Postfix) with ESMTP id 9D64715666 for ; Fri, 19 Nov 1999 08:40:57 -0800 (PST) (envelope-from grog@mojave.sitaranetworks.com) Message-ID: <19991119113720.28959@mojave.sitaranetworks.com> Date: Fri, 19 Nov 1999 11:37:20 -0500 From: Greg Lehey To: Jonathon McKitrick Cc: rover@lglobus.ru, freebsd-questions@freebsd.org Subject: Re: Is there correct way for program to read from itself? Reply-To: Greg Lehey References: <19991119111026.11577@mojave.sitaranetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: ; from Jonathon McKitrick on Fri, Nov 19, 1999 at 04:16:49PM +0000 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Friday, 19 November 1999 at 16:16:49 +0000, Jonathon McKitrick wrote: > On Fri, 19 Nov 1999, Greg Lehey wrote: >>>>> Can't open copyme: No such file or directory >>>>> Everything is not that easy. >>>> That wasn't the question. But it can be fixed. How about you doing > > What happened here? Does he need a rehash command? WHy can't it find > copyme? (I'm just trying to learn something from all of this) No, he didn't do anything wrong, except to expect me to write a perfect program instead of an example. The relevant part of the code is: main (int argc, char *argv []) { int me = open (argv [0], O_RDONLY); argv [0] gets set to the name of the program (copyme). If I start it via PATH, it's still just "copyme". open(2) will fail if it doesn't find it in the current directory, and worse, if it *does* find a file of the same name, it will open it instead of the correct file. Greg -- When replying to this message, please copy the original recipients. For more information, see http://www.lemis.com/questions.html Finger grog@lemis.com for PGP public key See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message