]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
daemon-helper: send arbitrary signals via stdin
authorSage Weil <sage@inktank.com>
Sat, 6 Jul 2013 01:01:57 +0000 (18:01 -0700)
committerSage Weil <sage@inktank.com>
Mon, 8 Jul 2013 17:39:26 +0000 (10:39 -0700)
Each byte written to stdin will be interpreted as a signal.

Signed-off-by: Sage Weil <sage@inktank.com>
teuthology/task/ceph.py
teuthology/task/daemon-helper

index efe058426ee9b419855acc1bc5a0f593fcaeed6e..6234769617bc8661d976dbb3aab03ca5070edfaa 100644 (file)
@@ -4,6 +4,7 @@ import argparse
 import contextlib
 import logging
 import os
+import struct
 
 from teuthology import misc as teuthology
 from teuthology import contextutil
@@ -63,6 +64,9 @@ class DaemonState(object):
         self.proc = self.remote.run(*cmd_args, **cmd_kwargs)
         self.log.info('Started')
 
+    def signal(self, sig):
+        self.proc.stdin.write(struct.pack('!b', sig))
+        self.log.info('Sent signal %d', sig)
 
     def running(self):
         return self.proc is not None
index 51b990865af198c37fba32ed88688871f8761db7..6dc92b2ef0afc537d0946801f91b633abca28cc8 100755 (executable)
@@ -18,6 +18,7 @@ import fcntl
 import os
 import select
 import signal
+import struct
 import subprocess
 import sys
 
@@ -56,6 +57,9 @@ while True:
             saw_eof = True
             proc.send_signal(end_signal)
             break
+        else:
+            sig, = struct.unpack('!b', data)
+            proc.send_signal(sig)
 
     if proc.poll() is not None:
         # child exited