Can I remove the file of a server which is running?

  • Follow


I am experimenting with several tutorial "daytime" servers (UDP, TCP.
sync, async) which come with the C++ Boost libraries.

I was surprised to notice that, after the server was running:

(1) I was allowed to remove the executable (not being root at the
time)

(2) The server -much like the Energizer bunny- keeps on working.

Is that a feature that I can count on, or is something with
unpredictable results which should be avoided?

TIA,

-Ramon

Linux

0
Reply ramon (1465) 9/11/2009 3:03:03 PM

On September 11, 2009 11:03, in comp.unix.programmer, Ramon F Herrera
(ramon@conexus.net) wrote:

> 
> I am experimenting with several tutorial "daytime" servers (UDP, TCP.
> sync, async) which come with the C++ Boost libraries.
> 
> I was surprised to notice that, after the server was running:
> 
> (1) I was allowed to remove the executable (not being root at the
> time)

If your uid has write-permissions to a directory in which the executable
file is registered, your uid can remove the filename. That's the way file
permissions work in Unix. 

Remember that the file name is not the same as the file itself. The filename
within a directory is simply a pointer to the file. While you may be able
to remove the filename, the file itself
 a) may have other filenames in other directories, and
 b) won't go away until you delete *all* the filenames referring to it /and/
    close all filehandles currently accessing the file

> (2) The server -much like the Energizer bunny- keeps on working.

Yes, why should it not?


> Is that a feature that I can count on, or is something with
> unpredictable results which should be avoided?

It's how the system works. It is defined by both the Posix/SUS
standards, /and/ the Linux standards to work this way.

-- 
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/   | GPG public key available by request
----------      Slackware - Because I know what I'm doing.          ------


0
Reply lpitcher2 (869) 9/11/2009 3:14:18 PM


On Sep 11, 11:14=A0am, Lew Pitcher <lpitc...@teksavvy.com> wrote:
> On September 11, 2009 11:03, in comp.unix.programmer, Ramon F Herrera
>
> (ra...@conexus.net) wrote:
>
> > I am experimenting with several tutorial "daytime" servers (UDP, TCP.
> > sync, async) which come with the C++ Boost libraries.
>
> > I was surprised to notice that, after the server was running:
>
> > (1) I was allowed to remove the executable (not being root at the
> > time)
>
> If your uid has write-permissions to a directory in which the executable
> file is registered, your uid can remove the filename. That's the way file
> permissions work in Unix.
>
> Remember that the file name is not the same as the file itself. The filen=
ame
> within a directory is simply a pointer to the file. While you may be able
> to remove the filename, the file itself
> =A0a) may have other filenames in other directories, and
> =A0b) won't go away until you delete *all* the filenames referring to it =
/and/
> =A0 =A0 close all filehandles currently accessing the file
>
> > (2) The server -much like the Energizer bunny- keeps on working.
>

 > Yes, why should it not?

I do remember some time at a real Unix (not Linux) server, I tried to
remove a file and I got some message like "text is busy". That's why I
had that impression (not from crappy Windows).

-Ramon

0
Reply ramon (1465) 9/11/2009 3:36:15 PM

Ramon F Herrera wrote:
> [...]
> I do remember some time at a real Unix (not Linux) server, I tried to
> remove a file and I got some message like "text is busy". That's why I
> had that impression (not from crappy Windows).

     My guess is that you've misremembered the circumstances, and
that you were probably not trying to remove a file, but to overwrite
its content.  That's a different matter entirely.

-- 
Eric.Sosman@sun.com
0
Reply Eric.Sosman (4228) 9/11/2009 4:01:06 PM

On Sep 11, 12:01=A0pm, Eric Sosman <Eric.Sos...@sun.com> wrote:
> Ramon F Herrera wrote:
> > [...]
> > I do remember some time at a real Unix (not Linux) server, I tried to
> > remove a file and I got some message like "text is busy". That's why I
> > had that impression (not from crappy Windows).
>

 > My guess is that you've misremembered the circumstances,
 > and that you were probably not trying to remove a file,
 > but to overwrite its content.
 > That's a different matter entirely.

That could very well be the case, Eric.

Thx,

-Ramon

0
Reply ramon (1465) 9/11/2009 4:08:25 PM

In article <1252684861.34751@news1nwk>,
 Eric Sosman <Eric.Sosman@sun.com> wrote:

> Ramon F Herrera wrote:
> > [...]
> > I do remember some time at a real Unix (not Linux) server, I tried to
> > remove a file and I got some message like "text is busy". That's why I
> > had that impression (not from crappy Windows).
> 
>      My guess is that you've misremembered the circumstances, and
> that you were probably not trying to remove a file, but to overwrite
> its content.  That's a different matter entirely.

I don't think he's misremembered.  There were some versions of Unix that 
performed this check in rm.  A little googling found a mention of HPUX 
10 doing this.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
0
Reply barmar (5627) 9/12/2009 1:39:45 AM

5 Replies
33 Views

(page loaded in 0.08 seconds)

Similiar Articles:













7/24/2012 6:35:19 PM


Reply: