* Add configuration option to specify the user to run as.

This commit is contained in:
Justin Maggard
2012-07-18 18:58:26 +00:00
parent ccc32409c5
commit 1de4ef8bc1
10 changed files with 125 additions and 69 deletions

View File

@@ -86,41 +86,6 @@ daemonize(void)
return pid;
}
int
writepidfile(const char * fname, int pid)
{
char pidstring[16];
int pidstringlen;
int pidfile;
if(!fname || *fname == '\0')
return -1;
if( (pidfile = open(fname, O_WRONLY|O_CREAT, 0644)) < 0)
{
DPRINTF(E_ERROR, L_GENERAL, "Unable to open pidfile for writing %s: %s\n", fname, strerror(errno));
return -1;
}
pidstringlen = snprintf(pidstring, sizeof(pidstring), "%d\n", pid);
if(pidstringlen <= 0)
{
DPRINTF(E_ERROR, L_GENERAL,
"Unable to write to pidfile %s: snprintf(): FAILED\n", fname);
close(pidfile);
return -1;
}
else
{
if(write(pidfile, pidstring, pidstringlen) < 0)
DPRINTF(E_ERROR, L_GENERAL, "Unable to write to pidfile %s: %s\n", fname, strerror(errno));
}
close(pidfile);
return 0;
}
int
checkforrunning(const char * fname)
{