-
Notifications
You must be signed in to change notification settings - Fork 33
/
aria2-0004-option_processing-make-use-of-deamon-on-mingw.patch
47 lines (44 loc) · 1.65 KB
/
aria2-0004-option_processing-make-use-of-deamon-on-mingw.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 26816f5deb196c7000244b56edd55b17385381db Mon Sep 17 00:00:00 2001
From: myfreeer <[email protected]>
Date: Sat, 9 Jun 2018 15:24:29 +0800
Subject: [PATCH 4/4] option_processing: make use of --deamon on mingw
---
src/option_processing.cc | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/option_processing.cc b/src/option_processing.cc
index f9891fe..3952ed6 100644
--- a/src/option_processing.cc
+++ b/src/option_processing.cc
@@ -319,6 +319,22 @@ error_code::Value option_processing(Option& op, bool standalone,
}
}
if (standalone && op.getAsBool(PREF_DAEMON)) {
+#ifdef __MINGW32__
+ std::wstring daemonCmdLine = GetCommandLineW();
+ daemonCmdLine.append(L" --daemon=false");
+ STARTUPINFOW si = {};
+ PROCESS_INFORMATION pi = {};
+ si.dwFlags = STARTF_USESHOWWINDOW;
+ si.wShowWindow = FALSE;
+ BOOL bRet = CreateProcessW(
+ NULL, const_cast<LPWSTR>(daemonCmdLine.c_str()), NULL, NULL,
+ FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
+ if (bRet) {
+ CloseHandle(pi.hThread);
+ CloseHandle(pi.hProcess);
+ ExitProcess(0);
+ }
+#else // !__MINGW32__
#if defined(__GNUC__) && defined(__APPLE__)
// daemon() is deprecated on OSX since... forever.
// Silence the warning for good, so that -Werror becomes feasible.
@@ -334,6 +350,7 @@ error_code::Value option_processing(Option& op, bool standalone,
perror(MSG_DAEMON_FAILED);
return error_code::UNKNOWN_ERROR;
}
+#endif // __MINGW32__
}
if (op.getAsBool(PREF_DEFERRED_INPUT) && op.defined(PREF_SAVE_SESSION)) {
A2_LOG_WARN("--deferred-input is disabled because of the presence of "
--
2.17.1