From owner-freebsd-questions Fri Nov 19 8:43:43 1999 Delivered-To: freebsd-questions@freebsd.org Received: from serenity.mcc.ac.uk (serenity.mcc.ac.uk [130.88.200.93]) by hub.freebsd.org (Postfix) with ESMTP id 35D9615666 for ; Fri, 19 Nov 1999 08:43:40 -0800 (PST) (envelope-from jcm@dogma.freebsd-uk.eu.org) Received: from dogma.freebsd-uk.eu.org ([130.88.200.97]) by serenity.mcc.ac.uk with esmtp (Exim 1.92 #3) id 11or8O-000G4a-00; Fri, 19 Nov 1999 16:43:40 +0000 Received: from localhost (jcm@localhost) by dogma.freebsd-uk.eu.org (8.9.3/8.9.3) with SMTP id QAA25291; Fri, 19 Nov 1999 16:43:39 GMT (envelope-from jcm@dogma.freebsd-uk.eu.org) Date: Fri, 19 Nov 1999 16:43:39 +0000 (GMT) From: Jonathon McKitrick To: Greg Lehey Cc: rover@lglobus.ru, freebsd-questions@freebsd.org Subject: Re: Is there correct way for program to read from itself? In-Reply-To: <19991119113720.28959@mojave.sitaranetworks.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Ah, makes perfect sense. Thanks. On Fri, 19 Nov 1999, Greg Lehey wrote: > 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 > -jm --------- He who laughs last... obviously didn't get the joke. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message