* Add configuration option to specify the user to run as.
This commit is contained in:
35
daemonize.c
35
daemonize.c
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user