summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-10-08 16:11:13 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-10-08 16:11:13 -0400
commit6c9c496bb2885e8884d9120c388f692d6f404168 (patch)
tree9a73d254d5e7d559456c73396c88e3b2bce3ec0a
parent0fcbb6d4f8eb7e8d27b52304688a58e1bee5a7ca (diff)
downloadgpsd-6c9c496bb2885e8884d9120c388f692d6f404168.tar.gz
Implement SIGUSR1 behavior in gpspprof, and change the way samples are counted.
-rwxr-xr-xgpsprof11
-rw-r--r--gpsprof.xml4
2 files changed, 12 insertions, 3 deletions
diff --git a/gpsprof b/gpsprof
index 3ff8567b..f13d9cd2 100755
--- a/gpsprof
+++ b/gpsprof
@@ -6,7 +6,7 @@
# Collect and plot latency-profiling data from a running gpsd.
# Requires gnuplot.
#
-import sys, os, time, getopt, socket, math, copy
+import sys, os, time, getopt, socket, math, copy, signal
import gps
class Baton:
@@ -70,8 +70,10 @@ class plotter:
if self.requires_time:
options = ',"timing":true'
try:
+ signal.signal(signal.SIGUSR1, lambda empty, unused: sys.stderr.write("%d of %d (%d%%)..." % (await-countdown, await, ((await-countdown)*100.0//await))))
+ signal.siginterrupt(signal.SIGUSR1, False)
self.session.send('?WATCH={"enable":true,"json":true%s}' % options)
- baton = Baton("gpsprof: looking for fix", "done")
+ baton = Baton("gpsprof: %d looking for fix" % os.getpid(), "done")
countdown = await
basetime = time.time()
while countdown > 0:
@@ -109,6 +111,7 @@ class plotter:
baton.end()
finally:
self.session.send('?WATCH={"enable":false,"timing":false}')
+ signal.signal(signal.SIGUSR1, signal.SIG_DFL)
def dump(self):
"Dump the raw data for post-analysis."
return self.header() + self.data()
@@ -265,7 +268,9 @@ class instrumented(plotter):
self.session.data['sor'],
self.session.data['rtime'],
time.time()))
- return True
+ return True
+ else:
+ return False
def header(self):
res = "# Analyzed latency, " + self.whatami() + "\n"
res += "# Tag -- Fix time -- - Chars - -- Latency - RS232- Analysis - Recv -\n"
diff --git a/gpsprof.xml b/gpsprof.xml
index 06cc9fc2..d0be6bde 100644
--- a/gpsprof.xml
+++ b/gpsprof.xml
@@ -170,6 +170,10 @@ a usage message and exit.</para>
<para>The -D sets debug level.</para>
+<para>Sending SIGUSR to a running instance causes it to write a
+completion message to standard error and resume processing. The
+first number in the startup message is the process ID to signal.</para>
+
</refsect1>
<refsect1 id='see_also'><title>SEE ALSO</title>
<para>