added -n to qsehttpd

This commit is contained in:
hyung-hwan 2013-02-23 16:15:27 +00:00
parent 7984b065e1
commit e24161d184
4 changed files with 45 additions and 36 deletions

View File

@ -38,6 +38,10 @@
# include <openssl/engine.h> # include <openssl/engine.h>
#endif #endif
#if defined(HAVE_SYS_PRCTL_H)
# include <sys/prctl.h>
#endif
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static qse_httpd_t* g_httpd = QSE_NULL; static qse_httpd_t* g_httpd = QSE_NULL;
@ -1131,6 +1135,7 @@ static void print_usage (QSE_FILE* out, int argc, qse_char_t* argv[])
qse_fprintf (out, QSE_T(" --version show version\n")); qse_fprintf (out, QSE_T(" --version show version\n"));
qse_fprintf (out, QSE_T(" -c/--config-file file specify a configuration file\n")); qse_fprintf (out, QSE_T(" -c/--config-file file specify a configuration file\n"));
qse_fprintf (out, QSE_T(" -d/--daemon run in the background\n")); qse_fprintf (out, QSE_T(" -d/--daemon run in the background\n"));
qse_fprintf (out, QSE_T(" -n string specify a process name if supported\n"));
qse_fprintf (out, QSE_T(" -x output debugging messages\n")); qse_fprintf (out, QSE_T(" -x output debugging messages\n"));
} }
@ -1146,7 +1151,7 @@ static int handle_args (int argc, qse_char_t* argv[])
}; };
static qse_opt_t opt = static qse_opt_t opt =
{ {
QSE_T("c:dhx"), QSE_T("c:dhn:x"),
lng lng
}; };
qse_cint_t c; qse_cint_t c;
@ -1184,6 +1189,27 @@ static int handle_args (int argc, qse_char_t* argv[])
print_usage (QSE_STDOUT, argc, argv); print_usage (QSE_STDOUT, argc, argv);
return 0; return 0;
case QSE_T('n'):
{
/* i don't care about failure to set the name */
#if defined(HAVE_PRCTL)
#if !defined(PR_SET_NAME)
# define PR_SET_NAME 15
#endif
#if defined(QSE_CHAR_IS_MCHAR)
prctl (PR_SET_NAME, (unsigned long)opt.arg, 0, 0, 0);
#else
qse_mchar_t* mopt = qse_wcstombsdup (opt.arg, QSE_NULL, QSE_MMGR_GETDFL());
if (mopt)
{
prctl (PR_SET_NAME, (unsigned long)mopt, 0, 0, 0);
QSE_MMGR_FREE (QSE_MMGR_GETDFL(), mopt);
}
#endif
#endif
break;
}
case QSE_T('x'): case QSE_T('x'):
g_debug = 1; g_debug = 1;
break; break;

41
qse/configure vendored
View File

@ -17440,24 +17440,13 @@ fi
done done
for ac_header in crt_externs.h for ac_header in crt_externs.h prctl.h uci.h
do : do :
ac_fn_c_check_header_mongrel "$LINENO" "crt_externs.h" "ac_cv_header_crt_externs_h" "$ac_includes_default" as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if test "x$ac_cv_header_crt_externs_h" = xyes; then : ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define HAVE_CRT_EXTERNS_H 1 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in uci.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "uci.h" "ac_cv_header_uci_h" "$ac_includes_default"
if test "x$ac_cv_header_uci_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_UCI_H 1
_ACEOF _ACEOF
fi fi
@ -17569,12 +17558,13 @@ _ACEOF
fi fi
done done
for ac_func in sysconf for ac_func in sysconf prctl fdopendir
do : do :
ac_fn_c_check_func "$LINENO" "sysconf" "ac_cv_func_sysconf" as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
if test "x$ac_cv_func_sysconf" = xyes; then : ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define HAVE_SYSCONF 1 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF _ACEOF
fi fi
@ -17592,17 +17582,6 @@ _ACEOF
fi fi
done done
for ac_func in fdopendir
do :
ac_fn_c_check_func "$LINENO" "fdopendir" "ac_cv_func_fdopendir"
if test "x$ac_cv_func_fdopendir" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_FDOPENDIR 1
_ACEOF
fi
done
for ac_func in fork vfork posix_spawn gettid nanosleep select for ac_func in fork vfork posix_spawn gettid nanosleep select
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`

View File

@ -121,8 +121,7 @@ AC_CHECK_HEADERS([net/if.h net/if_dl.h], [], [], [
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>]) #include <sys/socket.h>])
AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h]) AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h])
AC_CHECK_HEADERS([crt_externs.h]) AC_CHECK_HEADERS([crt_externs.h prctl.h uci.h])
AC_CHECK_HEADERS([uci.h])
dnl check data types dnl check data types
AC_CHECK_TYPE([wchar_t], AC_CHECK_TYPE([wchar_t],
@ -140,9 +139,8 @@ AC_CHECK_FUNCS([isblank iswblank])
AC_CHECK_FUNCS([lseek64 stat64 fstat64 lstat64 ftruncate64 readdir64]) AC_CHECK_FUNCS([lseek64 stat64 fstat64 lstat64 ftruncate64 readdir64])
AC_CHECK_FUNCS([timegm timelocal]) AC_CHECK_FUNCS([timegm timelocal])
AC_CHECK_FUNCS([utime utimes]) AC_CHECK_FUNCS([utime utimes])
AC_CHECK_FUNCS([sysconf]) AC_CHECK_FUNCS([sysconf prctl fdopendir])
AC_CHECK_FUNCS([backtrace backtrace_symbols]) AC_CHECK_FUNCS([backtrace backtrace_symbols])
AC_CHECK_FUNCS([fdopendir])
AC_CHECK_FUNCS([fork vfork posix_spawn gettid nanosleep select]) AC_CHECK_FUNCS([fork vfork posix_spawn gettid nanosleep select])
AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext]) AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext])
AC_CHECK_FUNCS([_vsnprintf _vsnwprintf]) AC_CHECK_FUNCS([_vsnprintf _vsnwprintf])

View File

@ -299,6 +299,12 @@
/* Define to 1 if you have the `powl' function. */ /* Define to 1 if you have the `powl' function. */
#undef HAVE_POWL #undef HAVE_POWL
/* Define to 1 if you have the `prctl' function. */
#undef HAVE_PRCTL
/* Define to 1 if you have the <prctl.h> header file. */
#undef HAVE_PRCTL_H
/* Define if libtool can extract symbol lists from object files. */ /* Define if libtool can extract symbol lists from object files. */
#undef HAVE_PRELOADED_SYMBOLS #undef HAVE_PRELOADED_SYMBOLS