Methods for autoupdating fpc programs?

classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Methods for autoupdating fpc programs?

Bo Berglund
I am wondering if there is some method to autoupdate an fpc program
running on a RaspberryPi? It really should not matter where the fpc
program runs but I figured the operating system has some influence, so
let's limit this to Linux.

What I would like is to endow my data collection control program on a
Pi with the ability to check for updates on the web and then update
itself. But I have no clue as to the best way to do this.

The program will probably be started by cron every minute to check if
it has anything to do and if so execute its data collection task and
quit. Otherwise just quit, but here maybe also check for an update on
the web?
But how could one exchange a running program on the pi from within
itself?

Any common methods available somewhere?

--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

wkitty42
On 10/03/2015 02:30 PM, Bo Berglund wrote:
> The program will probably be started by cron every minute to check if
> it has anything to do and if so execute its data collection task and
> quit. Otherwise just quit, but here maybe also check for an update on
> the web?
> But how could one exchange a running program on the pi from within
> itself?

off the top of my head:

since you're running from cron and exiting, this could be pretty simple...

1. at start up, check if self is named known temp name. if yes, copy self to
normal name, spawn normal name and die.
2. at start up pull md5 checksum file from server and compare with own md5 checksum.
3. if md5 sums are different, download new version to known temp name.
4. at end of execution, see if known temp name exists. if it does, spawn it and die.

maybe something like that... of course, somewhere in there you'll still do your
required processing... the end of execution will wait for everything to be done
before doing step 4...

one might also use a special command line parameter to tell the known temp name
to copy itself over to the normal name in step 1.

--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list* unless
        private contact is specifically requested and granted.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Ralf Quint
In reply to this post by Bo Berglund
On 10/3/2015 11:30 AM, Bo Berglund wrote:

> I am wondering if there is some method to autoupdate an fpc program
> running on a RaspberryPi? It really should not matter where the fpc
> program runs but I figured the operating system has some influence, so
> let's limit this to Linux.
>
> What I would like is to endow my data collection control program on a
> Pi with the ability to check for updates on the web and then update
> itself. But I have no clue as to the best way to do this.
>
> The program will probably be started by cron every minute to check if
> it has anything to do and if so execute its data collection task and
> quit. Otherwise just quit, but here maybe also check for an update on
> the web?
> But how could one exchange a running program on the pi from within
> itself?
>
> Any common methods available somewhere?
>
Well, there is a Lazarus component for that... ;-)

http://wiki.freepascal.org/LazAutoUpdater

Ralf

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Bo Berglund
On Sat, 3 Oct 2015 13:58:27 -0700, Ralf Quint
<[hidden email]> wrote:

>On 10/3/2015 11:30 AM, Bo Berglund wrote:
>> I am wondering if there is some method to autoupdate an fpc program
>> running on a RaspberryPi? It really should not matter where the fpc
>> program runs but I figured the operating system has some influence, so
>> let's limit this to Linux.
>>
>> What I would like is to endow my data collection control program on a
>> Pi with the ability to check for updates on the web and then update
>> itself. But I have no clue as to the best way to do this.
>>
>> The program will probably be started by cron every minute to check if
>> it has anything to do and if so execute its data collection task and
>> quit. Otherwise just quit, but here maybe also check for an update on
>> the web?
>> But how could one exchange a running program on the pi from within
>> itself?
>>
>> Any common methods available somewhere?
>>
>Well, there is a Lazarus component for that... ;-)
>
>http://wiki.freepascal.org/LazAutoUpdater
>

Yes, I found that but it seems to be a visual component that will
interact with a user.
My program is a command line application started by cron and running
on a headless Pi2B installed inside a box in the wilderness. Only
communicates via a mobile broadband modem/router...
I need a non-visual one.
And I did not intend to host my program on Sourceforge either...


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Ralf Quint
On 10/3/2015 2:15 PM, Bo Berglund wrote:
> Yes, I found that but it seems to be a visual component that will
> interact with a user. My program is a command line application started
> by cron and running on a headless Pi2B installed inside a box in the
> wilderness. Only communicates via a mobile broadband modem/router... I
> need a non-visual one. And I did not intend to host my program on
> Sourceforge either...

Well, then run a shell script in cron instead of the executable direct.
And before starting the executable in that script, check for the
existence of a new version that your application has downloaded, and if
existent, copy it over the existing one and remove the download...
That's a basic method that will work for pretty much any application,
not only on written in FPC...

Ralf


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Bo Berglund
In reply to this post by wkitty42
On Sat, 3 Oct 2015 15:04:31 -0400, waldo kitty
<[hidden email]> wrote:

>On 10/03/2015 02:30 PM, Bo Berglund wrote:
>> The program will probably be started by cron every minute to check if
>> it has anything to do and if so execute its data collection task and
>> quit. Otherwise just quit, but here maybe also check for an update on
>> the web?
>> But how could one exchange a running program on the pi from within
>> itself?
>
>off the top of my head:
>
>since you're running from cron and exiting, this could be pretty simple...
>
>1. at start up, check if self is named known temp name. if yes, copy self to
>normal name, spawn normal name and die.
>2. at start up pull md5 checksum file from server and compare with own md5 checksum.
>3. if md5 sums are different, download new version to known temp name.

Would this not compare equal for the exact same version? All others
including old and newer would fail and thus trigger an update.
BTW, how does one get the md5 value of ones own executable file?

>4. at end of execution, see if known temp name exists. if it does, spawn it and die.
>
>maybe something like that... of course, somewhere in there you'll still do your
>required processing... the end of execution will wait for everything to be done
>before doing step 4...
>
>one might also use a special command line parameter to tell the known temp name
>to copy itself over to the normal name in step 1.

Interesting ideas, will have to think about it.

I have not programmed in Linux before so I have no idea if programs
for Linux carry a version resource that can be checked for the version
number. Is this the case or is that only a Windows thingie?

If not then the MD5 checksum seems to be a good way...

I just tested on Lazarus inside the Pi2B and it was simple to do a MD5
sum of one's own executable:

strMD5 := MD5Print(MD5File(Application.Exename));

The only problem is that it seems to take quite some time to do
(several seconds) is that normal?

--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Bo Berglund
On Sat, 03 Oct 2015 23:40:01 +0200, Bo Berglund
<[hidden email]> wrote:

>I just tested on Lazarus inside the Pi2B and it was simple to do a MD5
>sum of one's own executable:
>
>strMD5 := MD5Print(MD5File(Application.Exename));
>
>The only problem is that it seems to take quite some time to do
>(several seconds) is that normal?

OUCH!
My test application created in Lazarus contains a single small form
with two edit boxes and two buttons.
THe code behind each button is 3-4 lines each invoking MD5 functions.

I was intrigued by the location of the executable shown in the
messages box:
/root/tmp/project1
So I decided to go there and have a look at the file itself.
This is what I found (had to do sudo su to be allowed to view this
location):
-rwxr-xr-x 1 root root 24493881 Oct  3 21:35 project1

So this little program is 24.5 Mbytes in size!
Amazing and no wonder the MD5 calculation takes such a long time!
Why is FPC producing such an incredibly big program file?

And why is Lazarus running as root? I would have believed it was using
the Pi user rather than root? (Maybe this is a Lazarus question rather
than FPC).

--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Sven Barth-2

Am 03.10.2015 23:56 schrieb "Bo Berglund" <[hidden email]>:
> So this little program is 24.5 Mbytes in size!
> Amazing and no wonder the MD5 calculation takes such a long time!
> Why is FPC producing such an incredibly big program file?

That's the debug information. If you disable the generation of the debug information or tell the compiler to use an external file for that (both options are available in the project options), then the size should be around 1.5 MB (or was it 3?). However the size is only growing very slowly with each added form/control/code as the bulk of it stems from the LCL (so a pure console application as you plan is much smaller anyway).

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Jonas Maebe-2
In reply to this post by Bo Berglund
Bo Berglund wrote:
> So this little program is24.5  Mbytes in size!
> Amazing and no wonder the MD5 calculation takes such a long time!

Program size and speed are generally not directly correlated (think of
e.g. inlining, which increases program size and which can also increase
speed at the same time).

> Why is FPC producing such an incredibly big program file?

a) you have debug info enabled
b) you don't have dead code stripping (a.k.a. "smart linking") enabled

This also suggests you are creating a debug build, which additionally
means you probably don't have any optimisations enabled.

> And why is Lazarus running as root?

Because you presumably started it as root. If you start an application
as a normal user, it cannot get root permissions (unless your lazarus
binary is marked as setuid root, but that's unlikely).


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Sven Barth-2

Am 04.10.2015 00:02 schrieb "Jonas Maebe" <[hidden email]>:
>
> Bo Berglund wrote:
>>
>> So this little program is24.5  Mbytes in size!
>>
>> Amazing and no wonder the MD5 calculation takes such a long time!
>
>
> Program size and speed are generally not directly correlated (think of e.g. inlining, which increases program size and which can also increase speed at the same time).

In this case it is, because he generates a checksum of the running binary ;)

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Bo Berglund
In reply to this post by Jonas Maebe-2
On Sun, 04 Oct 2015 00:02:01 +0200, Jonas Maebe
<[hidden email]> wrote:

>> And why is Lazarus running as root?
>
>Because you presumably started it as root. If you start an application
>as a normal user, it cannot get root permissions (unless your lazarus
>binary is marked as setuid root, but that's unlikely).

If that is the case then my entire VNC session must be running as root
rather than user pi...

I have no idea how this happens since I only connect on the IP:5900
socket and the desktop is displayed on which I start Lazarus from the
Menu. There is no user login required where the active user is set.

But if I open a terminal from the menu in the VNC window it shows it
is running as root...

I have to check with the RPi forum on this VNC problem.

--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Bo Berglund
On Sun, 04 Oct 2015 00:36:09 +0200, Bo Berglund
<[hidden email]> wrote:

>But if I open a terminal from the menu in the VNC window it shows it
>is running as root...
>
>I have to check with the RPi forum on this VNC problem.

I have now found out the reason for the VNC shell running as root and
I have managed to get it half way solved...

It had to do with how tightvncserver was initialized following
installation and how the vncboot script was written for starting vnc
server on boot. The tutorial I used for freepascal and lazarus on pi
had a section on vnc access too so I used that when installing rather
than the official documentation tutorial on the pi website.

In any case I have now found it and tried to modify the installation
and vncboot script so that the VNC shell runs as pi. And this sems to
have succeeded.
But in the process ALL of the start menu programs in the VNC shell
disappeared! I now only have Run.., which does nothing, and Shutdown.
Plus the file manager and terminal on separate start icons. These two
show that the shell now runs as user pi.

But I have no idea how to get to Lazarus anymore since it disappeared
from the Menu. And I am not that used to Linux that I can fix this.
Sigh....
Maybe I have to scrap the SDcard and start over (another day lost).

--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Mark Morgan Lloyd-5
Bo Berglund wrote:

> On Sun, 04 Oct 2015 00:36:09 +0200, Bo Berglund
> <[hidden email]> wrote:
>
>> But if I open a terminal from the menu in the VNC window it shows it
>> is running as root...
>>
>> I have to check with the RPi forum on this VNC problem.
>
> I have now found out the reason for the VNC shell running as root and
> I have managed to get it half way solved...
>
> It had to do with how tightvncserver was initialized following
> installation and how the vncboot script was written for starting vnc
> server on boot. The tutorial I used for freepascal and lazarus on pi
> had a section on vnc access too so I used that when installing rather
> than the official documentation tutorial on the pi website.
>
> In any case I have now found it and tried to modify the installation
> and vncboot script so that the VNC shell runs as pi. And this sems to
> have succeeded.
> But in the process ALL of the start menu programs in the VNC shell
> disappeared! I now only have Run.., which does nothing, and Shutdown.
> Plus the file manager and terminal on separate start icons. These two
> show that the shell now runs as user pi.
>
> But I have no idea how to get to Lazarus anymore since it disappeared
> from the Menu. And I am not that used to Linux that I can fix this.
> Sigh....
> Maybe I have to scrap the SDcard and start over (another day lost).

This is not the place to discuss this but hopefully Management will
allow a single message through, after that we will need to adjourn to
fpc-other.

There are three ways of running VNC. The first- and most common- is to
start it up to look at an already-running session for remote support
etc., which is probably what you've done.

The other two start it up listening to a TCP port, one way is to use
inetd.conf and the other is to use inittab /but/ this latter doesn't
work on Jessie or later (there might be an equivalent way to plumb it
into systemd but I've not managed yet). Either of these ways will start
up a new copy of the system's default display manager (lightdm or
whatever), and at that point you can log in as an arbitrary user with
your usual desktop... it is probably this that you're missing.

Otherwise, AS A NUMBER OF PEOPLE INCLUDING MYSELF HAVE TOLD YOU
REPEATEDLY, you can quite simply run Lazarus- and I mean Lazarus,
complete with its GUI stuff- over SSH. This is by far the simplest way,
although as I've said elsewhere there can be a performance impact.

If you want to continue this, please start a thread in either fpc-other
or lazarus-other asking about running Lazarus remotely.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Mark Morgan Lloyd-5
In reply to this post by wkitty42
waldo kitty wrote:

> On 10/03/2015 02:30 PM, Bo Berglund wrote:
>> The program will probably be started by cron every minute to check if
>> it has anything to do and if so execute its data collection task and
>> quit. Otherwise just quit, but here maybe also check for an update on
>> the web?
>> But how could one exchange a running program on the pi from within
>> itself?
>
> off the top of my head:
>
> since you're running from cron and exiting, this could be pretty simple...
>
> 1. at start up, check if self is named known temp name. if yes, copy
> self to normal name, spawn normal name and die.
> 2. at start up pull md5 checksum file from server and compare with own
> md5 checksum.

Check size first in case somebody has inadvertently put up a binary with
a couple of dozen Mb debug info attached :-)

One way round this is to use (something like) Subversion at both ends of
the link, since this implements a fairly efficient check and is
generally OK for binaries.

> 3. if md5 sums are different, download new version to known temp name.
> 4. at end of execution, see if known temp name exists. if it does, spawn
> it and die.
>
> maybe something like that... of course, somewhere in there you'll still
> do your required processing... the end of execution will wait for
> everything to be done before doing step 4...
>
> one might also use a special command line parameter to tell the known
> temp name to copy itself over to the normal name in step 1.

i)   Does the program need to detect changes while it's running?

ii)  What provision is made for ensuring that a new version of the
program comes from the designated builder?

iii) Assuming that the program's not being rebuilt from source on the
machine it's to run on, does the binary name include the name of the
architecture etc.?

I've looked a bit at (i) for graphical programs. It can be done fairly
reliably using dynamically-linked libraries (.so files on unix) but not
IME quite reliably enough for remote sites. And while we're in the UK,
we have kit scattered around from Sweden to Turkey.

Code signing is not really implemented on Linux, so (ii) is a problem.

Considering (iii), Lazarus can be told to put the architecture etc. in
the name of a generated binary, but going further than that- and in
particular specifying subarchitectures like the HF on the RPi- is a
problem hardly helped by the fact that there's no provision for this in
the ELF header.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Graeme Geldenhuys-6
In reply to this post by Bo Berglund
On 2015-10-03 19:30, Bo Berglund wrote:
> But how could one exchange a running program on the pi from within
> itself?

On non-Windows platforms it is much easier, because you can normally
replace a program on file, while it is running in memory. Windows
doesn't allow that. Either way the solution is quite simple for most
platforms.

tiOPF's 'tiopf_apps' repository includes one such solution. In summary,
the program checks for updates at startup - using HTTP, a database or
whatever. If a update exists, launch the update program and quit. The
update program will then fetch the update, and unpack the archive, then
launch the original program and quit itself.

For our desktop applications will added a message prompt to ask the
end-user if the want to update, but for a automated system you obviously
don't want that part. This solution has worked for us in production site
for a good few years already.

Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Mattias Gaertner
On Sun, 4 Oct 2015 12:37:29 +0100
Graeme Geldenhuys <[hidden email]> wrote:

> On 2015-10-03 19:30, Bo Berglund wrote:
> > But how could one exchange a running program on the pi from within
> > itself?
>
> On non-Windows platforms it is much easier, because you can normally
> replace a program on file, while it is running in memory. Windows
> doesn't allow that. Either way the solution is quite simple for most
> platforms.

That is not entirely true.

Replacing a running program by simply copying can result under Linux in
'text file busy'.

You can rename a running executable, allowing to copy a new
version. This works on Windows and Linux.

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Graeme Geldenhuys-6
On 2015-10-04 13:16, Mattias Gaertner wrote:
> Replacing a running program by simply copying can result under Linux in
> 'text file busy'.

Then consider me luckily. :) In my 15 years of using Linux and 4 years
of FreeBSD I have never seen that error.

As an example, while developing I always run my programs for a console
window. I often rebuild the program, while the previous one was still
running. With Linux and FreeBSD that never gives an error, but under
Windows it will say it couldn't link the executable.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Michael Van Canneyt


On Sun, 4 Oct 2015, Graeme Geldenhuys wrote:

> On 2015-10-04 13:16, Mattias Gaertner wrote:
>> Replacing a running program by simply copying can result under Linux in
>> 'text file busy'.
>
> Then consider me luckily. :) In my 15 years of using Linux and 4 years
> of FreeBSD I have never seen that error.

I see it nearly every day, when I recompile a fastcgi process that is still in use by Apache.

But I was also surprised to see it. I'm still not sure what the exact cause is,
because it works sometimes, and sometimes not.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Mark Morgan Lloyd-5
Michael Van Canneyt wrote:

> On Sun, 4 Oct 2015, Graeme Geldenhuys wrote:
>
>> On 2015-10-04 13:16, Mattias Gaertner wrote:
>>> Replacing a running program by simply copying can result under Linux in
>>> 'text file busy'.
>>
>> Then consider me luckily. :) In my 15 years of using Linux and 4 years
>> of FreeBSD I have never seen that error.
>
> I see it nearly every day, when I recompile a fastcgi process that is
> still in use by Apache.
>
> But I was also surprised to see it. I'm still not sure what the exact
> cause is, because it works sometimes, and sometimes not.

It generally happens if the OS (almost any OS) decides that constrained
resources means that a segment can usefully be removed from memory, and
further decides that it's a read-only segment so rather than writing it
to swap it will- if it needs it again- reread it from the original binary.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Methods for autoupdating fpc programs?

Jürgen Hestermann


Am 2015-10-04 um 15:41 schrieb Mark Morgan Lloyd:

> Michael Van Canneyt wrote:
>> On Sun, 4 Oct 2015, Graeme Geldenhuys wrote:
>>
>>> On 2015-10-04 13:16, Mattias Gaertner wrote:
>>>> Replacing a running program by simply copying can result under Linux in
>>>> 'text file busy'.
>>>
>>> Then consider me luckily. :) In my 15 years of using Linux and 4 years
>>> of FreeBSD I have never seen that error.
>>
>> I see it nearly every day, when I recompile a fastcgi process that is still in use by Apache.
>>
>> But I was also surprised to see it. I'm still not sure what the exact cause is, because it works sometimes, and sometimes not.
>
> It generally happens if the OS (almost any OS) decides that constrained resources means that a segment can usefully be removed from memory, and further decides that it's a read-only segment so rather than writing it to swap it will- if it needs it again- reread it from the original binary.
>

But that makes no sense to me. If the OS is designed to potentially remove running programs (or parts of it) from memory it cannot allow overwriting the file on disk in any case. When it does so, it cannot remove parts from memory because it may not be available on disk anymore. So it must disallow the disk change from the beginning, otherwise it may not be able to remove anything.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12