From fdebf40f342d368efee7d9bdf8d0cbf1d489f097 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 5 Jul 2013 18:01:57 -0700 Subject: [PATCH] daemon-helper: send arbitrary signals via stdin Each byte written to stdin will be interpreted as a signal. Signed-off-by: Sage Weil --- teuthology/task/ceph.py | 4 ++++ teuthology/task/daemon-helper | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index efe058426e..6234769617 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -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 diff --git a/teuthology/task/daemon-helper b/teuthology/task/daemon-helper index 51b990865a..6dc92b2ef0 100755 --- a/teuthology/task/daemon-helper +++ b/teuthology/task/daemon-helper @@ -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 -- 2.39.5