ithewei 6 tahun lalu
induk
melakukan
2ed649a2be
5 mengubah file dengan 12 tambahan dan 13 penghapusan
  1. 1 1
      Makefile
  2. 1 0
      hplatform.h
  3. 0 1
      hproc.h
  4. 0 1
      hthread.h
  5. 10 10
      main.cpp.tmpl

+ 1 - 1
Makefile

@@ -72,7 +72,7 @@ else
 ifeq ($(OS), Android)
 	LDFLAGS += -Wl,-Bdynamic -llog -lm
 else
-	LDFLAGS += -Wl,-Bdynamic -lstdc++ -lpthread -lm
+	LDFLAGS += -Wl,-Bdynamic -lstdc++ -lpthread -lm -ldl
 endif
 endif
 

+ 1 - 0
hplatform.h

@@ -7,6 +7,7 @@
     #define _CRT_NONSTDC_NO_DEPRECATE
     #include <winsock2.h>
     #include <windows.h>
+    #include <process.h> // for getpid,exec
     #include <direct.h> // for mkdir,rmdir,chdir,getcwd
 
     #define strcasecmp stricmp

+ 0 - 1
hproc.h

@@ -38,7 +38,6 @@ inline int create_proc(proc_ctx_t* ctx) {
 }
 #elif defined(_WIN32)
 // win32 use multi-threads
-#include <process.h>
 inline int create_proc(proc_ctx_t* ctx) {
     HANDLE h = (HANDLE)_beginthread(ctx->proc, 0, ctx->userdata);
     if (h == NULL) {

+ 0 - 1
hthread.h

@@ -9,7 +9,6 @@
 #include "hplatform.h"
 
 #ifdef _WIN32
-#define getpid GetCurrentProcessId
 #define gettid GetCurrentThreadId
 #endif
 

+ 10 - 10
main.cpp.tmpl

@@ -34,16 +34,16 @@ static void worker_proc(void* userdata);
 
 // unix short style
 static char options[] = "hvc:ts:dp:";
-static char detail_options[] = "\
--h              : print help\n\
--v              : print version\n\
--c  confile     : set configure file, default etc/${program}.conf\n\
--t              : test configure file and exit\n\
--s  signal      : send signal to process\n\
-                  signal=[start, stop, restart, status]\n\
--d              : daemon\n\
--p  port        : set listen port\n\
-";
+static char detail_options[] = R"(
+-h              : print help
+-v              : print version
+-c  confile     : set configure file, default etc/${program}.conf
+-t              : test configure file and exit
+-s  signal      : send signal to process
+                  signal=[start, stop, restart, status]
+-d              : daemon
+-p  port        : set listen port
+)";
 
 void print_version() {
     printf("%s version %s\n", g_main_ctx.program_name, get_compile_version());