Okay, this is legitimately cool as heck. This finally helps me wrap my head around the “everything is a file” concept in Linux. Of course it can just copy the executable to memory for later reference. That’s how the system would not completely have a meltdown when you do live updates.

Excellent share!

It's a bit more interesting than that...

Linux, unlike Windows, will let you delete a file that is actively in use. It removes the reference on the file system but the contents of the file won't be deleted until all file pointers to it close. In fact it will still be seen as taking up disk space until it's garbage collected (deleting a large file that's in use can be frustrating).

So the file is actually still available to that running process. If you replace it with a new executable and run that then you get the new version.

Julia Evans has such great and accessible content, they're awesome

they are a youtuber?

Better, they make zines! https://jvns.ca/

thanks, it's got really hard nowdays to find quality content.

Do you know how to build portable executables?

configure --prefix=/proc/self/pwd

It even works in .so files and libtool.

How would this differ from --prefix=$(pwd) ?

--prefix=$(pwd) is resolved at compile time. If you move your compiled .so files to a different directory, they stop working.

I see what you mean, very clever solution if a program is using the configure prefix by compiling it into the binary.

That can't be very common though is it? Usually the configure prefix is just used by make install to install the binaries into the prefix. If the compiled program needs to know where it is installed it can read argv[0].

Have you seen this used somewhere?

This is awesome, and I really no no idea about this!

I no no idea you liked this, nice

d'oh! That's what I get for trying to type quickly.

That's ok, sometimes I to to type quickly too

Subscribe.

I know what a symlink is, but what is a magic symlink?

A symlink that has been blessed by Richard Stallman.

If you delete a file that's still open by the app, the link in proc will still exist and you can copy the file back out of proc.

Does that not make them a hard link (pointing to a filesystem node) instead of a symlink (pointing to another filename)?

No, you can't have a hard link cross filesystems and proc is its own fs type.

Great tips! Although if i may 🤓 just a little for the top right, it works because what you deleted isn't the binary, it's the pointer that points to the binary's location. The data is still exactly as it was before "deletion"; the symlink is simply a copy of the original pointer's info; and I'm speculating that the existence of any pointer prevents the system from recycling those addressed bits.

it merely deletes the inode from the directory instead of overwriting the actual data on the disk

Thank you for sharing this. Got a new creator to check out now!

midwest.social

Rules

  1. No porn.
  2. No bigotry, hate speech.
  3. No ads / spamming.
  4. No conspiracies / QAnon / antivaxx sentiment
  5. No zionists
  6. No fascists

Chat Room

Matrix chat room: https://matrix.to/#/#midwestsociallemmy:matrix.org

Communities

Communities from our friends:

Donations

LiberaPay link: https://liberapay.com/seahorse