Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jul 1996 13:32:54 -0400 (EDT)
From:      "Brian M. Clapper" <bmc@WillsCreek.COM>
To:        "Thomas S. Traylor" <tst@titan.cs.mci.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How do you write to an executable (binary)?
Message-ID:  <199607061732.NAA01056@current.willscreek.com>
In-Reply-To: <76092049@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "Thomas" == Thomas S Traylor <tst@titan.cs.mci.com> writes:

Thomas> Here's what I'm trying to do:

Thomas> I have a program that will prompt the user for a value.  I would
Thomas> like to write that value to the executable (binary) file.  (Using
Thomas> open, lseek, write, close)

Thomas> Problem:

Thomas> When I open the file I get the following error:

Thomas> "Error: Text file busy".  The message number is [ETXTBSY].

Thomas> I'm able to do this with other OS.  How can I get this to work with
Thomas> FreeBSD? Any ideas or suggestions would be greatly appreciated.

That means the executable is in use--i.e., someone's running it.  If you
have enough space on the file system, you can eliminate that problem this
way:

1. Copy the executable to a uniquely temporary file in the same directory,
   and be sure to preserve the ownership and permission settings.
2. Update the temporary file with your value.
3. Unlink the original.
4. Rename the temporary to the original.

Of course, this whole topic begs the obvious question: Why are you updating
an executable in this way?
-----
Brian Clapper ....................... bmc@WillsCreek.COM -or- bmc@telebase.com
http://www.netaxs.com/~bmc/ ......... PGP public key available on request
The first and great commandment is: Do not let them scare you.
        -- Elmer Davis



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