forked from MusicPlayerDaemon/MPD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
407db96
commit e3cf9bb
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// Copyright The Music Player Daemon Project | ||
|
||
#include "Main.hxx" | ||
#include "Instance.hxx" | ||
#include "CommandLine.hxx" | ||
#include "net/Init.hxx" | ||
#include "config/Data.hxx" | ||
|
||
static int service_argc; | ||
static char **service_argv; | ||
|
||
int apple_main(int argc, char *argv[]) | ||
{ | ||
service_argc = argc; | ||
service_argv = argv; | ||
|
||
#ifdef ENABLE_DAEMON | ||
CommandLineOptions options; | ||
ConfigData raw_config; | ||
|
||
ParseCommandLine(argc, argv, options, raw_config); | ||
|
||
if (options.daemon) { | ||
// Fork before any Objective-C runtime initializations | ||
pid_t pid = fork(); | ||
if (pid < 0) | ||
throw MakeErrno("fork() failed"); | ||
|
||
if (pid > 0) { | ||
// Parent process: exit immediately | ||
_exit(0); | ||
} | ||
} | ||
#endif | ||
|
||
return mpd_main(argc, argv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters