But how does it work? How is the program started if there has to be a - infront of the name? How do you set argv[0] when executing something?
int execl(const char *pathname, const char *arg, ...);
Normally you would call it like execl("program", "program", "argument", NULL), duplicating the program's name/path, but it's possible to set the 2nd argument, which corresponds to argv[0] (in the case of execl), to something different. This behaviour just isn't always exposed in the shell and other languages.You can set it yourself within a running program as well, like:
perl -e '$0="testme";while(1){sleep 1}' &
ps -ef | grep testme