Commit 82dc8c1a authored by kernc's avatar kernc

pgrep is no longer required (issue 13)

git-svn-id: https://logkeys.googlecode.com/svn/trunk@36 c501e62c-e7d1-11de-a198-37193048d1ed
parent 1177d16e
......@@ -120,7 +120,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@
FOUND_PS = @FOUND_PS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
......
......@@ -599,7 +599,7 @@ EGREP
GREP
CXXCPP
FOUND_DUMPKEYS
FOUND_PGREP
FOUND_PS
FOUND_GREP
am__fastdepCXX_FALSE
am__fastdepCXX_TRUE
......@@ -3424,15 +3424,15 @@ fi
if test x"$FOUND_GREP" = xno ; then
as_fn_error "Required program grep is missing." "$LINENO" 5
fi
# Extract the first word of "pgrep", so it can be a program name with args.
set dummy pgrep; ac_word=$2
# Extract the first word of "ps", so it can be a program name with args.
set dummy ps; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_FOUND_PGREP+set}" = set; then :
if test "${ac_cv_prog_FOUND_PS+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$FOUND_PGREP"; then
ac_cv_prog_FOUND_PGREP="$FOUND_PGREP" # Let the user override the test.
if test -n "$FOUND_PS"; then
ac_cv_prog_FOUND_PS="$FOUND_PS" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
......@@ -3441,7 +3441,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_FOUND_PGREP="yes"
ac_cv_prog_FOUND_PS="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
......@@ -3449,21 +3449,21 @@ done
done
IFS=$as_save_IFS
test -z "$ac_cv_prog_FOUND_PGREP" && ac_cv_prog_FOUND_PGREP="no"
test -z "$ac_cv_prog_FOUND_PS" && ac_cv_prog_FOUND_PS="no"
fi
fi
FOUND_PGREP=$ac_cv_prog_FOUND_PGREP
if test -n "$FOUND_PGREP"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $FOUND_PGREP" >&5
$as_echo "$FOUND_PGREP" >&6; }
FOUND_PS=$ac_cv_prog_FOUND_PS
if test -n "$FOUND_PS"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $FOUND_PS" >&5
$as_echo "$FOUND_PS" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test x"$FOUND_PGREP" = xno ; then
as_fn_error "Required program pgrep is missing." "$LINENO" 5
if test x"$FOUND_PS" = xno ; then
as_fn_error "Required program ps is missing." "$LINENO" 5
fi
# Extract the first word of "dumpkeys", so it can be a program name with args.
set dummy dumpkeys; ac_word=$2
......
......@@ -18,9 +18,9 @@ AC_CHECK_PROG([FOUND_GREP], [grep], [yes], [no])
if test x"$FOUND_GREP" = xno ; then
AC_MSG_ERROR([Required program grep is missing.])
fi
AC_CHECK_PROG([FOUND_PGREP], [pgrep], [yes], [no])
if test x"$FOUND_PGREP" = xno ; then
AC_MSG_ERROR([Required program pgrep is missing.])
AC_CHECK_PROG([FOUND_PS], [ps], [yes], [no])
if test x"$FOUND_PS" = xno ; then
AC_MSG_ERROR([Required program ps is missing.])
fi
AC_CHECK_PROG([FOUND_DUMPKEYS], [dumpkeys], [yes], [no])
if test x"$FOUND_DUMPKEYS" = xno ; then
......
......@@ -90,7 +90,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@
FOUND_PS = @FOUND_PS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
......
......@@ -89,7 +89,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@
FOUND_PS = @FOUND_PS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
......
......@@ -83,7 +83,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@
FOUND_PS = @FOUND_PS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
......
......@@ -213,8 +213,7 @@ int main(int argc, char **argv) {
FILE *temp_file = fopen(TMP_PID_FILE, "r");
pid_t pid;
if ((temp_file != NULL && fscanf(temp_file, "%d", &pid) == 1 && fclose(temp_file) == 0) ||
(sscanf( exec("pgrep logkeys").c_str(), "%d", &pid) == 1 && pid != getpid())) { // if reading PID from temp_file failed, try pgrep pipe
// TODO: replace pgrep with 'ps ax | grep taskname | grep -v grep'
(sscanf(exec((std::string("ps ax | grep '") + argv[0] + "' | grep -v grep").c_str()).c_str(), "%d", &pid) == 1 && pid != getpid())) { // if reading PID from temp_file failed, try ps pipe
remove(TMP_PID_FILE);
kill(pid, SIGINT);
return EXIT_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment