You can create a folder in /var/run named 'myapp', owned by the user of your program, and then write the pid file to /var/run/myapp/myapp.pid (I assume it is a daemon of some sort).