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@ ...@@ -120,7 +120,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@ FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@ FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@ FOUND_PS = @FOUND_PS@
GREP = @GREP@ GREP = @GREP@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
......
...@@ -599,7 +599,7 @@ EGREP ...@@ -599,7 +599,7 @@ EGREP
GREP GREP
CXXCPP CXXCPP
FOUND_DUMPKEYS FOUND_DUMPKEYS
FOUND_PGREP FOUND_PS
FOUND_GREP FOUND_GREP
am__fastdepCXX_FALSE am__fastdepCXX_FALSE
am__fastdepCXX_TRUE am__fastdepCXX_TRUE
...@@ -3424,15 +3424,15 @@ fi ...@@ -3424,15 +3424,15 @@ fi
if test x"$FOUND_GREP" = xno ; then if test x"$FOUND_GREP" = xno ; then
as_fn_error "Required program grep is missing." "$LINENO" 5 as_fn_error "Required program grep is missing." "$LINENO" 5
fi fi
# Extract the first word of "pgrep", so it can be a program name with args. # Extract the first word of "ps", so it can be a program name with args.
set dummy pgrep; ac_word=$2 set dummy ps; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; } $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 $as_echo_n "(cached) " >&6
else else
if test -n "$FOUND_PGREP"; then if test -n "$FOUND_PS"; then
ac_cv_prog_FOUND_PGREP="$FOUND_PGREP" # Let the user override the test. ac_cv_prog_FOUND_PS="$FOUND_PS" # Let the user override the test.
else else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH for as_dir in $PATH
...@@ -3441,7 +3441,7 @@ do ...@@ -3441,7 +3441,7 @@ do
test -z "$as_dir" && as_dir=. test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do 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 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 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2 break 2
fi fi
...@@ -3449,21 +3449,21 @@ done ...@@ -3449,21 +3449,21 @@ done
done done
IFS=$as_save_IFS 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
fi fi
FOUND_PGREP=$ac_cv_prog_FOUND_PGREP FOUND_PS=$ac_cv_prog_FOUND_PS
if test -n "$FOUND_PGREP"; then if test -n "$FOUND_PS"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $FOUND_PGREP" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FOUND_PS" >&5
$as_echo "$FOUND_PGREP" >&6; } $as_echo "$FOUND_PS" >&6; }
else else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; } $as_echo "no" >&6; }
fi fi
if test x"$FOUND_PGREP" = xno ; then if test x"$FOUND_PS" = xno ; then
as_fn_error "Required program pgrep is missing." "$LINENO" 5 as_fn_error "Required program ps is missing." "$LINENO" 5
fi fi
# Extract the first word of "dumpkeys", so it can be a program name with args. # Extract the first word of "dumpkeys", so it can be a program name with args.
set dummy dumpkeys; ac_word=$2 set dummy dumpkeys; ac_word=$2
......
...@@ -18,9 +18,9 @@ AC_CHECK_PROG([FOUND_GREP], [grep], [yes], [no]) ...@@ -18,9 +18,9 @@ AC_CHECK_PROG([FOUND_GREP], [grep], [yes], [no])
if test x"$FOUND_GREP" = xno ; then if test x"$FOUND_GREP" = xno ; then
AC_MSG_ERROR([Required program grep is missing.]) AC_MSG_ERROR([Required program grep is missing.])
fi fi
AC_CHECK_PROG([FOUND_PGREP], [pgrep], [yes], [no]) AC_CHECK_PROG([FOUND_PS], [ps], [yes], [no])
if test x"$FOUND_PGREP" = xno ; then if test x"$FOUND_PS" = xno ; then
AC_MSG_ERROR([Required program pgrep is missing.]) AC_MSG_ERROR([Required program ps is missing.])
fi fi
AC_CHECK_PROG([FOUND_DUMPKEYS], [dumpkeys], [yes], [no]) AC_CHECK_PROG([FOUND_DUMPKEYS], [dumpkeys], [yes], [no])
if test x"$FOUND_DUMPKEYS" = xno ; then if test x"$FOUND_DUMPKEYS" = xno ; then
......
...@@ -90,7 +90,7 @@ EGREP = @EGREP@ ...@@ -90,7 +90,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@ FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@ FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@ FOUND_PS = @FOUND_PS@
GREP = @GREP@ GREP = @GREP@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
......
...@@ -89,7 +89,7 @@ EGREP = @EGREP@ ...@@ -89,7 +89,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@ FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@ FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@ FOUND_PS = @FOUND_PS@
GREP = @GREP@ GREP = @GREP@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
......
...@@ -83,7 +83,7 @@ EGREP = @EGREP@ ...@@ -83,7 +83,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FOUND_DUMPKEYS = @FOUND_DUMPKEYS@ FOUND_DUMPKEYS = @FOUND_DUMPKEYS@
FOUND_GREP = @FOUND_GREP@ FOUND_GREP = @FOUND_GREP@
FOUND_PGREP = @FOUND_PGREP@ FOUND_PS = @FOUND_PS@
GREP = @GREP@ GREP = @GREP@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
......
...@@ -213,8 +213,7 @@ int main(int argc, char **argv) { ...@@ -213,8 +213,7 @@ int main(int argc, char **argv) {
FILE *temp_file = fopen(TMP_PID_FILE, "r"); FILE *temp_file = fopen(TMP_PID_FILE, "r");
pid_t pid; pid_t pid;
if ((temp_file != NULL && fscanf(temp_file, "%d", &pid) == 1 && fclose(temp_file) == 0) || 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 (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
// TODO: replace pgrep with 'ps ax | grep taskname | grep -v grep'
remove(TMP_PID_FILE); remove(TMP_PID_FILE);
kill(pid, SIGINT); kill(pid, SIGINT);
return EXIT_SUCCESS; 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