From owner-freebsd-questions Sun Jul 7 04:21:56 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id EAA29355 for questions-outgoing; Sun, 7 Jul 1996 04:21:56 -0700 (PDT) Received: from proxy.siemens.at (proxy.siemens.at [192.138.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id EAA29165 for ; Sun, 7 Jul 1996 04:21:47 -0700 (PDT) Received: from sol1.gud.siemens.co.at (sol-f.gud.siemens-austria) by proxy.siemens.at with SMTP id AA19719 (5.67a/IDA-1.5 for ); Sun, 7 Jul 1996 13:21:07 +0200 Received: from ws2301.gud.siemens.co.at by sol1.gud.siemens.co.at with smtp (Smail3.1.28.1 #7 for ) id m0ucrtk-00021RC; Sun, 7 Jul 96 13:21 MET DST Received: by ws2301.gud.siemens.co.at (1.37.109.16/1.37) id AA080148382; Sun, 7 Jul 1996 13:19:42 +0200 From: "Hr.Ladavac" Message-Id: <199607071119.AA080148382@ws2301.gud.siemens.co.at> Subject: Re: How do you write to an executable (binary)? To: tst@titan.cs.mci.com (Thomas S. Traylor) Date: Sun, 7 Jul 1996 13:19:42 +0200 (MESZ) Cc: questions@freebsd.org In-Reply-To: from "Thomas S. Traylor" at Jul 6, 96 08:46:46 am X-Mailer: ELM [version 2.4 PL24 ME8a] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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