I made a few changes and since this forum isn't too public, I think I can post a bit of code in here

- I moved the unlinking code into unix_main.c in Sys_Exit - that way all kinds of exits will remove the PID file
- The unlink code uses Cvar_VariableStringBuffer("sv_pidfile", pidfile, sizeof(pidfile)); to get the pid file name (Cvar_Get also inits the Cvar if it does not exist)
- The code creating the PID file uses c_pid = Cvar_Get ("sv_pidfile", va("/var/run/%s.pid", basename(argv[0])) , CVAR_INIT); i.e. basename and CVAR_INIT. The first should be obvious


Just FYI, a modified patch for this part is here (EDit: @Smoking Guns: don't collect this path - it will be part of the bigger one for 0.4)
I probably won't change things for chroot/setuid stuff. In these cases, the user should know what he's doing and will have to take care about a number of other things, too, anyways
