def kill_spawned_process(self):
"""
Kill spawned process inside container.
If process of `docker exec` was killed, the spawned process inside container is
still running. So we should kill spawned process before kill `docker exec`.
"""
p = PtyProcessUnicode.spawn(['docker', 'exec', self.container_id, '/bin/sh', '-c',
'kill -1 $(cat /tmp/sh.pid.{})'.format(self.uuid)])
# wait till complete execution of command
while p.isalive():
sleep(1)
p.close()
评论列表
文章目录