Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux daemon issue #2572

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/mangosd/CliRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,8 @@ void CliRunnable::operator()()
}
sWorld.QueueCliCommand(new CliCommandHolder(0, SEC_CONSOLE, nullptr, command.c_str(), &utf8print, &commandFinished));
}
#ifndef WIN32
free(command_str);
imranh2 marked this conversation as resolved.
Show resolved Hide resolved
#endif
}
}
2 changes: 1 addition & 1 deletion src/mangosd/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ extern int main(int argc, char **argv)

// and run the 'Master'
// TODO: Why do we need this 'Master'? Can't all of this be in the Main as for Realmd?
return sMaster.Run();
return sMaster.Run(serviceDaemonMode);

// at sMaster return function exist with codes
// 0 - normal shutdown
Expand Down
4 changes: 2 additions & 2 deletions src/mangosd/Master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Master::~Master()
}

// Main function
int Master::Run()
int Master::Run(char serviceDaemonMode = '\0')
{
// worldd PID file creation
std::string pidfile = sConfig.GetStringDefault("PidFile", "");
Expand Down Expand Up @@ -210,7 +210,7 @@ int Master::Run()
#ifdef WIN32
if (sConfig.GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
#else
if (sConfig.GetBoolDefault("Console.Enable", true))
if (sConfig.GetBoolDefault("Console.Enable", true) && !serviceDaemonMode)
#endif
{
// Launch CliRunnable thread
Expand Down
2 changes: 1 addition & 1 deletion src/mangosd/Master.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Master
public:
Master();
~Master();
int Run();
int Run(char serviceDaemonMode);
static volatile uint32 m_masterLoopCounter;
static volatile bool m_handleSigvSignals;
static void SigvSignalHandler();
Expand Down
6 changes: 0 additions & 6 deletions src/shared/PosixDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,9 @@ void startDaemon(uint32_t timeout)
exit(EXIT_FAILURE);
}

if ((chdir("/")) < 0)
{
exit(EXIT_FAILURE);
}

close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);

}

void stopDaemon()
Expand Down