Skip to content

Commit

Permalink
Revert "Fix linux daemon issue (#2572)"
Browse files Browse the repository at this point in the history
This reverts commit 657d4f5.
  • Loading branch information
ratkosrb committed Jun 21, 2024
1 parent 17cc7bc commit 76eaa9f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/mangosd/CliRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,5 @@ void CliRunnable::operator()()
sWorld.QueueCliCommand(new CliCommandHolder(0, SEC_CONSOLE, nullptr, command.c_str(), &utf8print, &commandFinished));
}
}
#ifndef WIN32
free(command_str);
#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(serviceDaemonMode);
return sMaster.Run();

// 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(char serviceDaemonMode = '\0')
int Master::Run()
{
// worldd PID file creation
std::string pidfile = sConfig.GetStringDefault("PidFile", "");
Expand Down Expand Up @@ -210,7 +210,7 @@ int Master::Run(char serviceDaemonMode = '\0')
#ifdef WIN32
if (sConfig.GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
#else
if (sConfig.GetBoolDefault("Console.Enable", true) && !serviceDaemonMode)
if (sConfig.GetBoolDefault("Console.Enable", true))
#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(char serviceDaemonMode);
int Run();
static volatile uint32 m_masterLoopCounter;
static volatile bool m_handleSigvSignals;
static void SigvSignalHandler();
Expand Down
6 changes: 6 additions & 0 deletions src/shared/PosixDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ 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

0 comments on commit 76eaa9f

Please sign in to comment.