mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-06 07:44:57 +03:00
Merge pull request #615 from prodatakey/foreground-logging
Merge PR #615: Foreground logging
This commit is contained in:
@ -133,6 +133,7 @@ BOOL kernel_status_inited = false; // Kernel state initialization flag
|
||||
bool g_little_endian = true;
|
||||
char *cmdline = NULL; // Command line
|
||||
wchar_t *uni_cmdline = NULL; // Unicode command line
|
||||
bool g_foreground = false; // Execute service in foreground mode
|
||||
|
||||
// Static variable
|
||||
static char *exename = NULL; // EXE file name (ANSI)
|
||||
@ -513,6 +514,12 @@ void InitMayaqua(bool memcheck, bool debug, int argc, char **argv)
|
||||
setbuf(stdout, NULL);
|
||||
}
|
||||
|
||||
#ifdef OS_UNIX
|
||||
g_foreground = (argc >= 3 && StrCmpi(argv[2], UNIX_SVC_ARG_FOREGROUND) == 0);
|
||||
#else
|
||||
g_foreground = false;
|
||||
#endif // OS_UNIX
|
||||
|
||||
// Acquisition whether NT
|
||||
#ifdef OS_WIN32
|
||||
is_nt = Win32IsNt();
|
||||
|
@ -395,6 +395,7 @@ extern char *cmdline;
|
||||
extern wchar_t *uni_cmdline;
|
||||
extern bool g_little_endian;
|
||||
extern LOCK *tick_manual_lock;
|
||||
extern bool g_foreground;
|
||||
|
||||
// Kernel state
|
||||
#define NUM_KERNEL_STATUS 128
|
||||
|
@ -1703,6 +1703,23 @@ void *UnixFileOpen(char *name, bool write_mode, bool read_lock)
|
||||
return (void *)p;
|
||||
}
|
||||
|
||||
// Get UNIXIO object for stdout
|
||||
void* GetUnixio4Stdout()
|
||||
{
|
||||
static UNIXIO unixio =
|
||||
{
|
||||
.fd = -1,
|
||||
.write_mode = true
|
||||
};
|
||||
|
||||
if (g_foreground)
|
||||
{
|
||||
unixio.fd = STDOUT_FILENO;
|
||||
return &unixio;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Return the current thread ID
|
||||
UINT UnixThreadId()
|
||||
{
|
||||
@ -2849,6 +2866,12 @@ RESTART_PROCESS:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (argc >= 3 && StrCmpi(argv[1], UNIX_SVC_ARG_START) == 0 && StrCmpi(argv[2], UNIX_SVC_ARG_FOREGROUND) == 0)
|
||||
{
|
||||
InitMayaqua(false, false, argc, argv);
|
||||
UnixExecService(name, start, stop);
|
||||
FreeMayaqua();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start normally
|
||||
|
@ -141,6 +141,7 @@ typedef void (SERVICE_FUNCTION)();
|
||||
#define UNIX_SVC_ARG_STOP "stop"
|
||||
#define UNIX_SVC_ARG_EXEC_SVC "execsvc"
|
||||
#define UNIX_ARG_EXIT "exit"
|
||||
#define UNIX_SVC_ARG_FOREGROUND "--foreground"
|
||||
|
||||
#define UNIX_SVC_MODE_START 1
|
||||
#define UNIX_SVC_MODE_STOP 2
|
||||
@ -178,6 +179,7 @@ void *UnixFileOpen(char *name, bool write_mode, bool read_lock);
|
||||
void *UnixFileOpenW(wchar_t *name, bool write_mode, bool read_lock);
|
||||
void *UnixFileCreate(char *name);
|
||||
void *UnixFileCreateW(wchar_t *name);
|
||||
void *GetUnixio4Stdout();
|
||||
bool UnixFileWrite(void *pData, void *buf, UINT size);
|
||||
bool UnixFileRead(void *pData, void *buf, UINT size);
|
||||
void UnixFileClose(void *pData, bool no_flush);
|
||||
|
Reference in New Issue
Block a user