Hacker News new | ask | show | jobs
by SoftTalker 661 days ago
There's no guarantee that the name and the path are still the same executable that is running, or that they even exist anymore.
3 comments

In most of the variants of exec*() there are separate arguments for the thing to be executed and the *argv[] list. Argv[0] being the executable is just a convention. In perl $ARGV[0] is the first positional parameter. In

    $ perl myscript.pl a b c
$ARGV[0] is "a".
I mean sure. All software is built on assumptions. Make sure the assumptions you’re making are appropriate in context.
Unless you are on Windows
You can actually rename an executable that is running, on Windows. That's a way to handle self updates: rename the executable, create its replacement, execute the new one to make it remove the old executable.