From owner-freebsd-questions Sun Jul 7 05:36:36 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id FAA29864 for questions-outgoing; Sun, 7 Jul 1996 05:36:36 -0700 (PDT) Received: from ime.net (ime.net [204.97.248.4]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id FAA29841 for ; Sun, 7 Jul 1996 05:36:34 -0700 (PDT) Received: from kimiko.tcguy.net (buxton-3.ime.net [206.231.148.132]) by ime.net (8.7.4/8.6.12) with SMTP id IAA11012; Sun, 7 Jul 1996 08:35:57 -0400 (EDT) Message-ID: <31DFAF68.4E12@ime.net> Date: Sun, 07 Jul 1996 08:36:56 -0400 From: Gary Chrysler Reply-To: tcg@ime.net Organization: The Computer Guy X-Mailer: Mozilla 3.0b4Gold (Win95; I) MIME-Version: 1.0 To: "Hr.Ladavac" CC: "Thomas S. Traylor" , questions@FreeBSD.ORG Subject: Re: How do you write to an executable (binary)? References: <199607071119.AA080148382@ws2301.gud.siemens.co.at> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Hr.Ladavac wrote: > > In his e-mail Thomas S. Traylor wrote: > > Here's what I'm trying to do: > > > > I have a program that will prompt the user for a value. I would like to > > write that value to the executable (binary) file. (Using open, lseek, > > write, close) > > > > Problem: > > > > When I open the file I get the following error: > > > > "Error: Text file busy". The message number is [ETXTBSY]. > > > > I'm able to do this with other OS. How can I get this to work with > > FreeBSD? Any ideas or suggestions would be greatly appreciated. > > AFAIK, you cannot change the executable image from under itself (nor > while file is in use--being executed). > > What you can do is: > > 1) copy executable to executable.new > 2) edit executable.new to your heart's content (it is not in use :) > 3) move executable.new to executable. > > Beware: all processes that started executing the executable prior to point > 3) will not see the changes in the image (namely, they will still be using > or having access to the *old* executable, which is basically marked deleted > but referenced/in use and remains on disk until it is no longer referenced). > > /Marino Seems to me like it would be easier to whip up a setup program. -Enjoy Gary ~~~~~~~~~~~~~~~~ Improve America's Knowledge... Share yours The Borg... Where minds meet (207) 929-3848