Date: Sun, 07 Jul 1996 08:36:56 -0400 From: Gary Chrysler <tcg@ime.net> To: "Hr.Ladavac" <lada@ws2301.gud.siemens.co.at> Cc: "Thomas S. Traylor" <tst@titan.cs.mci.com>, questions@FreeBSD.ORG Subject: Re: How do you write to an executable (binary)? Message-ID: <31DFAF68.4E12@ime.net> References: <199607071119.AA080148382@ws2301.gud.siemens.co.at>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?31DFAF68.4E12>