aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c78
1 files changed, 14 insertions, 64 deletions
diff --git a/src/main.c b/src/main.c
index cf34eb989..30324cea2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,9 +60,6 @@
#define SYSTEM_CONFIG_FILE_LOCATION "/etc/mpd.conf"
#define USER_CONFIG_FILE_LOCATION "/.mpdconf"
-volatile int masterPid = 0;
-volatile int mainPid = 0;
-
typedef struct _Options {
int kill;
int daemon;
@@ -312,47 +309,6 @@ static void openDB(Options * options, char *argv0)
}
}
-static void startMainProcess(void)
-{
- int pid;
- fflush(0);
- pid = fork();
- if (pid > 0) {
- initInputStream();
- initReplayGainState();
-
- /* free stuff we don't need */
- freeAllListenSockets();
-
- mainPid = pid;
- masterInitSigHandlers();
- kill(mainPid, SIGUSR1);
- while (masterHandlePendingSignals() != COMMAND_RETURN_KILL)
- waitOnSignals();
- /* we're killed */
- playerKill();
-
- finishPlaylist();
-
- finishAudioConfig();
- finishAudioDriver();
-
- finishPaths();
-
- kill(mainPid, SIGTERM);
- waitpid(mainPid, NULL, 0);
- finishConf();
- close_log_files();
- exit(EXIT_SUCCESS);
-
- } else if (pid < 0) {
- ERROR("problems fork'ing main process!\n");
- exit(EXIT_FAILURE);
- }
-
- DEBUG("main process started!\n");
-}
-
static void daemonize(Options * options)
{
FILE *fp = NULL;
@@ -410,7 +366,6 @@ static void daemonize(Options * options)
DEBUG("writing pid file\n");
fprintf(fp, "%lu\n", (unsigned long)getpid());
fclose(fp);
- masterPid = getpid();
}
}
@@ -481,35 +436,30 @@ int main(int argc, char *argv[])
open_log_files(options.stdOutput);
- initPlayerData();
-
- initInputPlugins();
initPaths();
+ initPermissions();
+ initPlaylist();
+ initInputPlugins();
+
+ openDB(&options, argv[0]);
+
+ initCommands();
+ initPlayerData();
initAudioConfig();
initAudioDriver();
+ initVolume();
+ initInterfaces();
+ initReplayGainState();
initNormalization();
- initPlaylist();
- openDB(&options, argv[0]);
+ initInputStream();
daemonize(&options);
- initSigHandlers();
setup_log_output(options.stdOutput);
- startMainProcess();
- /* This is the main process which has
- * been forked from the master process.
- */
- initPermissions();
- initCommands();
- initVolume();
- initInterfaces();
- /* wait for the master process to get ready so we can start
- * playing if readPlaylistState thinks we should*/
- while (COMMAND_MASTER_READY != handlePendingSignals())
- my_usleep(1);
+ initSigHandlers();
openVolumeDevice();
read_state_file();
@@ -523,7 +473,7 @@ int main(int argc, char *argv[])
}
write_state_file();
-
+ playerKill();
freeAllInterfaces();
closeAllListenSockets();