texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[7862] ginfo test suite eliminate pgrep


From: gavinsmith0123
Subject: [7862] ginfo test suite eliminate pgrep
Date: Mon, 26 Jun 2017 15:59:50 -0400 (EDT)

Revision: 7862
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7862
Author:   gavin
Date:     2017-06-26 15:59:50 -0400 (Mon, 26 Jun 2017)
Log Message:
-----------
ginfo test suite eliminate pgrep

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/t/Init-inter.inc

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-06-26 19:42:02 UTC (rev 7861)
+++ trunk/ChangeLog     2017-06-26 19:59:50 UTC (rev 7862)
@@ -1,3 +1,10 @@
+2017-06-26  Gavin Smith  <address@hidden>
+
+       * info/t/Init-inter.inc (run_ginfo): Remove use of pgrep to get 
+       PID of process.  Get PID of ginfo process by running a subshell 
+       with "sh -c", printing the value of $$ (the shell PID), and then
+       exec'ing the ginfo program.
+
 2017-06-25  Gavin Smith  <address@hidden>
 
        * tp/Texinfor/Parser.pm, tp/Texinfo/Common.pm

Modified: trunk/info/t/Init-inter.inc
===================================================================
--- trunk/info/t/Init-inter.inc 2017-06-26 19:42:02 UTC (rev 7861)
+++ trunk/info/t/Init-inter.inc 2017-06-26 19:59:50 UTC (rev 7862)
@@ -101,55 +101,17 @@
     # interrupted.
     exec 7>&- ;
     exec 8>$FINISHEDFIFO ;
-    $GINFO $GINFO_OPTIONS "$@" ;
+    sh -c "echo \$\$ >&8 ; exec $GINFO $GINFO_OPTIONS $*" ;
     test $? -eq 0 || echo failure >$FINISHEDFIFO ;
     echo finished >$FINISHEDFIFO ; } 0<>$PTS_DEVICE 1<&0 &
   SUBSHELL=$!
   exec 8<$FINISHEDFIFO
 
+  read GINFO_PID <&8
+
   # Although we don't write to the FIFO in this process, we still need
   # to open it for writing, because if the above subshell exits before
   # we read from it, we won't be able to open it - even though 
   # "finished" is buffered.
   exec 9>$FINISHEDFIFO
-
-  # Check for pgrep
-  if findprog pgrep; then
-    # Get the PID of the running ginfo process.  Look for a process called
-    # "ginfo" whose parent process is the subshell executed by the previous
-    # command.
-    echo 'Fetching PID of ginfo process under test...' >&2
-    GINFO_PID=
-
-    # Try 3 times and then give up.  The process may never have started, 
-    # have started under a different name, or have already exited.
-    for i in 1 2 3; do
-      GINFO_PID=`pgrep -P $SUBSHELL $GINFO_NAME ; \
-       test $? -eq 0 || test $? -eq 1 || exit 99`
-
-      # This use of pgrep is likely not portable (works on procps).
-      # Check if it is likely to have worked.
-
-      # Exit status was anything other than 0 or 1
-      test $? -eq 99 && { GINFO_PID=unknown; break; }
-
-      # More than one line in output
-      echo $GINFO_PID | wc -l | grep '^0$\|^1$' >/dev/null \
-       || { GINFO_PID=unknown; break; }
-
-      # Non-numeral characters present
-      echo $GINFO_PID | grep -v '^[0-9]*$' >/dev/null
-      test $? -eq 0 && { GINFO_PID=unknown; break; }
-
-      GINFO_PID=`echo $GINFO_PID | tr -d '\n'`
-
-      test "$GINFO_PID" = "" || break
-      sleep 1 # Give subshell time to spawn ginfo process
-    done
-    test "$GINFO_PID" = "" && GINFO_PID=unknown
-    echo ...$GINFO_PID >&2
-  else
-    echo 'pgrep program not found - cannot get PID of ginfo process' >&2
-    GINFO_PID=unknown
-  fi
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]