mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-12 15:33:23 -05:00
fix pidfile for heavyweight threads
This commit is contained in:
parent
aad77eb53d
commit
ed0a9c9fb1
@ -55,6 +55,7 @@ typedef struct tag_config {
|
||||
int process_m3u; /**< Should we process m3u files? */
|
||||
int scan_type; /**< How hard to search mp3 files. see scan_get_mp3fileinfo() */
|
||||
int compress; /**< Should we compress? */
|
||||
int pid; /**< pid that will accept INT to terminate */
|
||||
char *adminpassword; /**< Password to web management pages */
|
||||
char *readpassword; /**< iTunes password */
|
||||
char *mp3dir; /**< root directory of the mp3 files */
|
||||
|
14
src/main.c
14
src/main.c
@ -612,6 +612,7 @@ void *signal_handler(void *arg) {
|
||||
|
||||
config.stop=0;
|
||||
config.reload=0;
|
||||
config.pid=getpid();
|
||||
|
||||
DPRINTF(E_WARN,L_MAIN,"Signal handler started\n");
|
||||
|
||||
@ -804,8 +805,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
daemon_start();
|
||||
|
||||
fprintf(pid_fp,"%d\n",getpid());
|
||||
fclose(pid_fp);
|
||||
/* just to be on the safe side... */
|
||||
config.pid=0;
|
||||
}
|
||||
|
||||
/* DWB: shouldn't this be done after dropping privs? */
|
||||
@ -824,6 +825,15 @@ int main(int argc, char *argv[]) {
|
||||
DPRINTF(E_FATAL,L_MAIN,"Error starting signal handler %s\n",strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
/* wait to for config.pid to be set by the signal handler */
|
||||
while(!config.pid) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
fprintf(pid_fp,"%d\n",config.pid);
|
||||
fclose(pid_fp);
|
||||
|
||||
DPRINTF(E_LOG,L_MAIN|L_PL,"Loading playlists\n");
|
||||
|
||||
if(config.playlist)
|
||||
|
Loading…
Reference in New Issue
Block a user