Skip to content
Snippets Groups Projects
Commit 83a9a00d authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#1791] Use XDG_CACHE_HOME to save pid file

parent ddaddc67
Branches
Tags
No related merge requests found
......@@ -60,13 +60,24 @@ main (int argc, char **argv)
unsigned int iPid = getpid();
char cPid[64], cOldPid[64];
sprintf (cPid,"%d", iPid);
std::string xdg_config, xdg_env, path;
// TODO Use $XDG_CACHE_HOME instead of $HOME
sprintf (homepid, "%s/.%s/%s", HOMEDIR, PROGDIR, PIDFILE);
sprintf (sfldir, "%s/.%s", HOMEDIR, PROGDIR);
xdg_config = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".cache/sflphone";
if (XDG_CACHE_HOME != NULL)
{
xdg_env = std::string (XDG_CACHE_HOME);
(xdg_env.length() > 0) ? path = xdg_env
: path = xdg_config;
}
else
path = xdg_config;
sprintf (sfldir, "%s", path.c_str ());
sprintf (homepid, "%s/%s", path.c_str (), PIDFILE);
if ( (fp = fopen (homepid,"r")) == NULL) {
// Check if $HOME/.sflphone directory exists or not.
// Check if $XDG_CACHE_HOME directory exists or not.
DIR *dir;
if ( (dir = opendir (sfldir)) == NULL) {
......@@ -95,6 +106,8 @@ main (int argc, char **argv)
else {
fclose (fp);
_debug ("SDLauiobvzsfivbsfivbsuobvsobvasbvfasdkbvkdbvbvksdbvksdbvkzsdbvasdfb: %i\n", atoi (cOldPid));
if (kill (atoi (cOldPid), 0) == SUCCESS) {
fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
exit (-1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment