I do not think you need another state variable while SQLite already has that information. Check out this and that. Using a file for this purpose may break things in the future. Still you may store the PID of the process in that file and check if it is still around before bailing out. In that case you need to trap kill signal and the like to make things smoother. But using a file is not the best way to go.
i'm aware that SQLite can be locked due to that info, but the point is to lock the whole program if there is an attempt to start the program again, and that only holds if another start of the program applies to the program in the same location. If the program is copied to another location then parallelizing it, isn't a problem.
also i know that using a file is not the best way to go, but it is the only way that seems easy and doable :) any other more elegant solution would be a more than welcome.
also since the location is the important factor storing PID wouldn't be of any use , would it ??????
also since the location is the important factor storing PID wouldn't be of any use , would it ??????
Yes, you can use PID along with the signals to prevent cases when the process is forced to die. As for the location you can use the same file to store location information for running instances as well. But probably you know that already.
You may also consider listening on a port and use sockets to request permission from the first instance. The fact that you can only listen a port once can be useful. Then you can store all information you need in a file and let the first instance control others.