Skip to content

Commit f5efcd9

Browse files
committed
Fixed build on windows
1 parent 7a3b28a commit f5efcd9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/sys/sig.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ int XUtils_Daemonize(int bNoChdir, int bNoClose)
6969
{
7070
#ifdef __linux__
7171
return daemon(bNoChdir, bNoClose);
72+
#elif _win32
73+
if (CreateProcess(NULL, NULL, NULL, NULL, FALSE,
74+
DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP,
75+
NULL, NULL, NULL, NULL) == 0) return -1;
76+
77+
if (!bNoChdir)
78+
{
79+
SetCurrentDirectory("C:\\");
80+
}
81+
82+
if (!bNoClose)
83+
{
84+
CloseHandle(GetStdHandle(STD_INPUT_HANDLE));
85+
CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE));
86+
CloseHandle(GetStdHandle(STD_ERROR_HANDLE));
87+
}
88+
89+
return 0;
7290
#else
7391
pid_t pid = fork();
7492
if (pid < 0) return -1;

0 commit comments

Comments
 (0)